mtp: Implement reading the OPC/DPC for little endian

This commit is contained in:
Holger Hans Peter Freyther 2015-03-24 19:01:40 +01:00
parent 953d4eda47
commit 0a8308764c
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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 = {