diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index 48b814eb27..d9f5fb7d18 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -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 diff --git a/openair3/UTILS/conversions.h b/openair3/UTILS/conversions.h index e188909713..dc275071c5 100644 --- a/openair3/UTILS/conversions.h +++ b/openair3/UTILS/conversions.h @@ -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) \