aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-20 12:20:46 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-20 13:11:29 +0100
commit925d566c188bfad3709e55ac223bee52ae2bc60c (patch)
tree6b382be23ce906e65d9903241e181cd6f57765d0 /include
parent460a8eb8654ae945ac73b46f5f078ced611a4478 (diff)
mtp: Fix the address mask, macro to extract opc/dpc
Fix the address mask, add macro to extract the DPC and OPC from an address. Write a test case for this.
Diffstat (limited to 'include')
-rw-r--r--include/mtp_level3.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/mtp_level3.h b/include/mtp_level3.h
index bc2d186..f311ad5 100644
--- a/include/mtp_level3.h
+++ b/include/mtp_level3.h
@@ -65,7 +65,7 @@
#define SCCP_SSA 0x01
#define MTP_LINK_MASK 0x0F
-#define MTP_ADDR_MASK 0x0FFF
+#define MTP_ADDR_MASK 0x3FFF
#define MTP_APOC_MASK 0x3f
@@ -77,6 +77,10 @@
((link) & MTP_LINK_MASK) << 28)
#define MTP_MAKE_APOC(apoc) \
(apoc & 0x3fff)
+#define MTP_ADDR_DPC(addr) \
+ (addr & MTP_ADDR_MASK)
+#define MTP_ADDR_OPC(addr) \
+ ((addr >> 14) & MTP_ADDR_MASK)
#elif __BYTE_ORDER == __BIG_ENDIAN
static inline uint32_t c_swap_32(uint32_t in)
{
@@ -97,6 +101,10 @@ static inline uint16_t c_swap_16(uint16_t in)
((link) & MTP_LINK_MASK) << 28)
#define MTP_MAKE_APOC(apoc) \
c_swap_16((apoc & 0x3fff))
+#define MTP_ADDR_DPC(addr) \
+ (c_swap_32(addr) & MTP_ADDR_MASK)
+#define MTP_ADDR_OPC(addr) \
+ ((c_swap_32(addr) >> 14) & MTP_ADDR_MASK)
#endif