Commit d5c229ae authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Use ENCODE_U24 in _5GSTrackingAreaIdList

parent 770d97d5
...@@ -63,8 +63,14 @@ typedef enum { ...@@ -63,8 +63,14 @@ typedef enum {
sIZE += sizeof(uint16_t) sIZE += sizeof(uint16_t)
#define DECODE_U24(bUFFER, vALUE, sIZE) \ #define DECODE_U24(bUFFER, vALUE, sIZE) \
vALUE = ntohl(*(uint32_t*) (bUFFER)) >> 8; \ do { \
sIZE += sizeof(uint8_t) + sizeof(uint16_t) uint32_t value_tmp = 0; \
uint8_t size_tmp = sizeof(uint8_t) + sizeof(uint16_t); \
memcpy((unsigned char*) &value_tmp, bUFFER, size_tmp); \
vALUE = ntohl(value_tmp); \
vALUE = vALUE >> 8; \
sIZE += size_tmp; \
} while (0)
#define DECODE_U32(bUFFER, vALUE, sIZE) \ #define DECODE_U32(bUFFER, vALUE, sIZE) \
vALUE = ntohl(*(uint32_t*) (bUFFER)); \ vALUE = ntohl(*(uint32_t*) (bUFFER)); \
...@@ -89,8 +95,12 @@ typedef enum { ...@@ -89,8 +95,12 @@ typedef enum {
size += sizeof(uint16_t) size += sizeof(uint16_t)
#define ENCODE_U24(buffer, value, size) \ #define ENCODE_U24(buffer, value, size) \
*(uint32_t*) (buffer) = htonl(value); \ do { \
size += sizeof(uint8_t) + sizeof(uint16_t) uint32_t value_tmp = htonl(value << 8); \
uint8_t size_tmp = sizeof(uint8_t) + sizeof(uint16_t); \
memcpy(buffer, (unsigned char*) &value_tmp, size_tmp); \
size += size_tmp; \
} while (0)
#define ENCODE_U32(buffer, value, size) \ #define ENCODE_U32(buffer, value, size) \
*(uint32_t*) (buffer) = htonl(value); \ *(uint32_t*) (buffer) = htonl(value); \
......
...@@ -87,12 +87,14 @@ int _5GSTrackingAreaIdList::encode_00_type( ...@@ -87,12 +87,14 @@ int _5GSTrackingAreaIdList::encode_00_type(
// Encode TAC list // Encode TAC list
for (int i = 0; i < item.tac_list.size(); i++) { for (int i = 0; i < item.tac_list.size(); i++) {
// TODO: use ENCODE_U24 // TODO: use ENCODE_U24
octet = (item.tac_list[i] & 0x00ff0000) >> 16; ENCODE_U24(buf + encoded_size, item.tac_list[i], encoded_size);
ENCODE_U8(buf + encoded_size, octet, encoded_size); /*
octet = (item.tac_list[i] & 0x0000ff00) >> 8; octet = (item.tac_list[i] & 0x00ff0000) >> 16;
ENCODE_U8(buf + encoded_size, octet, encoded_size); ENCODE_U8(buf + encoded_size, octet, encoded_size);
octet = (item.tac_list[i] & 0x000000ff) >> 0; octet = (item.tac_list[i] & 0x0000ff00) >> 8;
ENCODE_U8(buf + encoded_size, octet, encoded_size); ENCODE_U8(buf + encoded_size, octet, encoded_size);
octet = (item.tac_list[i] & 0x000000ff) >> 0;
ENCODE_U8(buf + encoded_size, octet, encoded_size);*/
} }
return encoded_size; return encoded_size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment