diff --git a/include/mtp/mtp_level3.h b/include/mtp/mtp_level3.h index 2395041f..eed3762f 100644 --- a/include/mtp/mtp_level3.h +++ b/include/mtp/mtp_level3.h @@ -71,6 +71,10 @@ ((link) & MTP_LINK_MASK) << 28) #define MTP_MAKE_APOC(apoc) \ (apoc & 0x3fff) +#define MTP_READ_DPC(addr) \ + (((addr) >> 0) & MTP_ADDR_MASK) +#define MTP_READ_OPC(addr) \ + (((addr) >> 14) & MTP_ADDR_MASK) #elif OSMO_IS_BIG_ENDIAN static inline uint32_t c_swap_32(uint32_t in) { @@ -91,6 +95,7 @@ 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)) +#error "Need to add MTP_READ_DPC/MTP_READ_OPC for big endian" #endif diff --git a/tests/mtp/mtp_parse_test.c b/tests/mtp/mtp_parse_test.c index 0e380778..80f1e4bf 100644 --- a/tests/mtp/mtp_parse_test.c +++ b/tests/mtp/mtp_parse_test.c @@ -599,6 +599,16 @@ int main(int argc, char **argv) check_prohib(tests[i].input, &tests[i].prohib); } + if (MTP_READ_OPC(tests[0].hdr.addr) != 91) { + fprintf(stderr, "Failed to read OPC address\n"); + abort(); + } + + if (MTP_READ_DPC(tests[1].hdr.addr) != 136) { + fprintf(stderr, "Failed to read DPC address\n"); + abort(); + } + /* check the SCCP unitdata */ { struct sccp_con_ctrl_prt_mgt prt = {