Create macro to ntoh_int16 buffer input

This commit is contained in:
Sakthivel Velumani
2023-11-01 21:13:20 -04:00
parent 21b269fa99
commit 128bd3d3db
2 changed files with 4 additions and 9 deletions
+1 -9
View File
@@ -968,14 +968,6 @@ static void parse_allowed_nssai(nr_nas_msg_snssai_t nssaiList[8], const uint8_t
}
}
static inline uint16_t ntohs_unaligned(const uint8_t *v)
{
// sanitize may complain on unaligned access, even if it works on Intel/AMD
uint16_t tmp;
memcpy(&tmp, v, sizeof(tmp));
return ntohs(tmp);
}
/* Extract Allowed NSSAI from Regestration Accept according to
3GPP TS 24.501 Table 8.2.7.1.1
*/
@@ -995,7 +987,7 @@ static void get_allowed_nssai(nr_nas_msg_snssai_t nssai[8], const uint8_t *pdu_b
const int type = *pdu_buffer++;
switch (type) {
case 0x77: // 5GS mobile identity
pdu_buffer += ntohs_unaligned(pdu_buffer) + sizeof(uint16_t);
pdu_buffer += ntoh_int16_buf(pdu_buffer) + sizeof(uint16_t);
break;
case 0x4A: // PLMN list
+3
View File
@@ -44,6 +44,9 @@
#define ntoh_int24_buf(bUF) \
((*bUF << 16) | ((*(bUF + 1)) << 8) | (*(bUF + 2)))
#define ntoh_int16_buf(bUF) \
((*(bUF) << 8) | (*(bUF + 1)))
#define IN_ADDR_TO_BUFFER(X,bUFF) INT32_TO_BUFFER((X).s_addr,(char*)bUFF)
#define IN6_ADDR_TO_BUFFER(X,bUFF) \