Structures and functions for converting integers to/from network byte order.
More...
#include <freeradius-devel/util/misc.h>
Go to the source code of this file.
|
static unsigned int | fr_bytes_from_bits (unsigned int bits) |
| Convert bits (as in prefix length) to bytes, rounding up. More...
|
|
static void | fr_nbo_from_int16 (uint8_t out[static sizeof(int16_t)], int16_t num) |
| Write out an signed 16bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_int32 (uint8_t out[static sizeof(int32_t)], int32_t num) |
| Write out an signed 32bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_int64 (uint8_t out[static sizeof(uint64_t)], uint64_t num) |
| Write out an signed 64bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_uint16 (uint8_t out[static sizeof(uint16_t)], uint16_t num) |
| Write out an unsigned 16bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_uint24 (uint8_t out[static 3], uint32_t num) |
| Write out an unsigned 24bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_uint32 (uint8_t out[static sizeof(uint32_t)], uint32_t num) |
| Write out an unsigned 32bit integer in wire format (big endian) More...
|
|
static void | fr_nbo_from_uint64 (uint8_t out[static sizeof(uint64_t)], uint64_t num) |
| Write out an unsigned 64bit integer in wire format (big endian) More...
|
|
static size_t | fr_nbo_from_uint64v (uint8_t out[static sizeof(uint64_t)], uint64_t num) |
| Write out an unsigned 64bit integer in wire format using the fewest bytes possible. More...
|
|
static uint64_t | fr_nbo_to_int64v (uint8_t const *data, size_t data_len) |
|
static uint16_t | fr_nbo_to_uint16 (uint8_t const data[static sizeof(uint16_t)]) |
| Read an unsigned 16bit integer from wire format (big endian) More...
|
|
static uint32_t | fr_nbo_to_uint24 (uint8_t const data[static 3]) |
| Read an unsigned 24bit integer from wire format (big endian) More...
|
|
static uint32_t | fr_nbo_to_uint32 (uint8_t const data[static sizeof(uint32_t)]) |
| Read an unsigned 32bit integer from wire format (big endian) More...
|
|
static uint64_t | fr_nbo_to_uint64 (uint8_t const data[static sizeof(uint64_t)]) |
| Read an unsigned 64bit integer from wire format (big endian) More...
|
|
static uint64_t | fr_nbo_to_uint64v (uint8_t const *data, size_t data_len) |
| Read an unsigned 64bit integer from wire format (big endian) with a variable length encoding. More...
|
|
Structures and functions for converting integers to/from network byte order.
- Author
- Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
- Copyright
- 2022 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
Definition in file nbo.h.
◆ fr_nbo_to_int16
◆ fr_nbo_to_int32
◆ fr_nbo_to_int64
◆ fr_bytes_from_bits()
static unsigned int fr_bytes_from_bits |
( |
unsigned int |
bits | ) |
|
|
inlinestatic |
Convert bits (as in prefix length) to bytes, rounding up.
- Parameters
-
bits | number of bits in the prefix |
- Returns
- number of bytes taken to store the prefix
Definition at line 235 of file nbo.h.
◆ fr_nbo_from_int16()
static void fr_nbo_from_int16 |
( |
uint8_t |
out[static sizeof(int16_t)], |
|
|
int16_t |
num |
|
) |
| |
|
inlinestatic |
Write out an signed 16bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 83 of file nbo.h.
◆ fr_nbo_from_int32()
static void fr_nbo_from_int32 |
( |
uint8_t |
out[static sizeof(int32_t)], |
|
|
int32_t |
num |
|
) |
| |
|
inlinestatic |
Write out an signed 32bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 94 of file nbo.h.
◆ fr_nbo_from_int64()
static void fr_nbo_from_int64 |
( |
uint8_t |
out[static sizeof(uint64_t)], |
|
|
uint64_t |
num |
|
) |
| |
|
inlinestatic |
Write out an signed 64bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 105 of file nbo.h.
◆ fr_nbo_from_uint16()
static void fr_nbo_from_uint16 |
( |
uint8_t |
out[static sizeof(uint16_t)], |
|
|
uint16_t |
num |
|
) |
| |
|
inlinestatic |
Write out an unsigned 16bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 38 of file nbo.h.
◆ fr_nbo_from_uint24()
Write out an unsigned 24bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 49 of file nbo.h.
◆ fr_nbo_from_uint32()
static void fr_nbo_from_uint32 |
( |
uint8_t |
out[static sizeof(uint32_t)], |
|
|
uint32_t |
num |
|
) |
| |
|
inlinestatic |
Write out an unsigned 32bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 61 of file nbo.h.
◆ fr_nbo_from_uint64()
static void fr_nbo_from_uint64 |
( |
uint8_t |
out[static sizeof(uint64_t)], |
|
|
uint64_t |
num |
|
) |
| |
|
inlinestatic |
Write out an unsigned 64bit integer in wire format (big endian)
- Parameters
-
[out] | out | Where to write the integer. |
[in] | num | to encode. |
Definition at line 72 of file nbo.h.
◆ fr_nbo_from_uint64v()
static size_t fr_nbo_from_uint64v |
( |
uint8_t |
out[static sizeof(uint64_t)], |
|
|
uint64_t |
num |
|
) |
| |
|
inlinestatic |
Write out an unsigned 64bit integer in wire format using the fewest bytes possible.
- Parameters
-
[out] | out | Where to write big endian encoding of num. Should be at least 8 bytes. |
[in] | num | Number to encode. |
- Returns
- the number of bytes written to out.
Definition at line 118 of file nbo.h.
◆ fr_nbo_to_int64v()
static uint64_t fr_nbo_to_int64v |
( |
uint8_t const * |
data, |
|
|
size_t |
data_len |
|
) |
| |
|
inlinestatic |
◆ fr_nbo_to_uint16()
static uint16_t fr_nbo_to_uint16 |
( |
uint8_t const |
data[static sizeof(uint16_t)] | ) |
|
|
inlinestatic |
Read an unsigned 16bit integer from wire format (big endian)
- Parameters
-
[in] | data | To convert to a 16bit unsigned integer of native endianness. |
- Returns
- a 16 bit unsigned integer of native endianness.
Definition at line 144 of file nbo.h.
◆ fr_nbo_to_uint24()
Read an unsigned 24bit integer from wire format (big endian)
- Parameters
-
[in] | data | To convert to a 24bit unsigned integer of native endianness. |
- Returns
- a 24 bit unsigned integer of native endianness.
Definition at line 155 of file nbo.h.
◆ fr_nbo_to_uint32()
static uint32_t fr_nbo_to_uint32 |
( |
uint8_t const |
data[static sizeof(uint32_t)] | ) |
|
|
inlinestatic |
Read an unsigned 32bit integer from wire format (big endian)
- Parameters
-
[in] | data | To convert to a 32bit unsigned integer of native endianness. |
- Returns
- a 32 bit unsigned integer of native endianness.
Definition at line 165 of file nbo.h.
◆ fr_nbo_to_uint64()
static uint64_t fr_nbo_to_uint64 |
( |
uint8_t const |
data[static sizeof(uint64_t)] | ) |
|
|
inlinestatic |
Read an unsigned 64bit integer from wire format (big endian)
- Parameters
-
[in] | data | To convert to a 64bit unsigned integer of native endianness. |
- Returns
- a 64 bit unsigned integer of native endianness.
Definition at line 175 of file nbo.h.
◆ fr_nbo_to_uint64v()
static uint64_t fr_nbo_to_uint64v |
( |
uint8_t const * |
data, |
|
|
size_t |
data_len |
|
) |
| |
|
inlinestatic |
Read an unsigned 64bit integer from wire format (big endian) with a variable length encoding.
- Parameters
-
[in] | data | Buffer containing the number. |
[in] | data_len | Length of number. |
- Returns
- a 64 bit unsigned integer of native endianness.
Definition at line 194 of file nbo.h.