Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
95707332
Commit
95707332
authored
Aug 27, 2024
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/TLV_Encoder_Fixes' into integration_2024_w34
parents
adc88d3d
9e643575
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
openair3/NAS/COMMON/UTIL/TLVEncoder.h
openair3/NAS/COMMON/UTIL/TLVEncoder.h
+28
-14
No files found.
openair3/NAS/COMMON/UTIL/TLVEncoder.h
View file @
95707332
...
...
@@ -24,24 +24,38 @@
#include <arpa/inet.h> // htonl, htons
#define ENCODE_U8(buffer, value, size) \
*(uint8_t*)(buffer) = value; \
size += sizeof(uint8_t)
#define ENCODE_U16(buffer, value, size) \
*(uint16_t*)(buffer) = htons(value); \
size += sizeof(uint16_t)
#define ENCODE_U24(buffer, value, size) \
*(uint32_t*)(buffer) = htonl(value); \
size += sizeof(uint8_t) + sizeof(uint16_t)
#define ENCODE_U8(buffer, value, size) \
do { \
*(uint8_t*)(buffer) = value; \
size += sizeof(uint8_t); \
} while (0)
/* Safely encodes a 16-bit value into a buffer, handling
misalignment by memcpy 2 bytes to buffer in network
byte order (big-endian). */
#define ENCODE_U16(buffer, value, size) \
do { \
uint16_t _val = htons(value); \
memcpy((buffer), &_val, sizeof(uint16_t)); \
size += sizeof(uint16_t); \
} while (0)
/* Safely encodes a 24-bit value into a buffer, handling
misalignment by using htonl and memcpy to copy 3 bytes
in network byte order (big-endian). */
#define ENCODE_U24(buffer, value, size) \
do { \
uint32_t _val = htonl(value); \
memcpy((buffer), ((uint8_t*)&_val) + 1, 3); \
size += sizeof(uint8_t) + sizeof(uint16_t); \
} while (0)
#define ENCODE_U32(buffer, value, size) \
{
\
do {
\
uint32_t tmp = htonl(value); \
memcpy(buffer, &tmp, sizeof(tmp)); \
}
\
size += sizeof(uint32_t
)
size += sizeof(uint32_t);
\
} while (0
)
#define IES_ENCODE_U8(buffer, encoded, value) \
ENCODE_U8(buffer + encoded, value, encoded)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment