29 if (length <
sizeof(uint16_t)) {
31 "Length (" << length <<
") of buffer is insufficient " <<
32 "to read a uint16_t");
35 const uint8_t* byte_buffer =
static_cast<const uint8_t*
>(buffer);
37 uint16_t result = (
static_cast<uint16_t
>(byte_buffer[0])) << 8;
38 result |=
static_cast<uint16_t
>(byte_buffer[1]);
56 if (length <
sizeof(uint16_t)) {
58 "Length (" << length <<
") of buffer is insufficient " <<
59 "to write a uint16_t");
62 uint8_t* byte_buffer =
static_cast<uint8_t*
>(buffer);
64 byte_buffer[0] =
static_cast<uint8_t
>((value & 0xff00U) >> 8);
65 byte_buffer[1] =
static_cast<uint8_t
>(value & 0x00ffU);
67 return (byte_buffer +
sizeof(uint16_t));
80 if (length <
sizeof(uint32_t)) {
82 "Length (" << length <<
") of buffer is insufficient " <<
83 "to read a uint32_t");
86 const uint8_t* byte_buffer =
static_cast<const uint8_t*
>(buffer);
88 uint32_t result = (
static_cast<uint32_t
>(byte_buffer[0])) << 24;
89 result |= (
static_cast<uint32_t
>(byte_buffer[1])) << 16;
90 result |= (
static_cast<uint32_t
>(byte_buffer[2])) << 8;
91 result |= (
static_cast<uint32_t
>(byte_buffer[3]));
106 if (length <
sizeof(uint64_t)) {
108 "Length (" << length <<
") of buffer is insufficient " <<
109 "to read a uint64_t");
112 const uint8_t* byte_buffer =
static_cast<const uint8_t*
>(buffer);
114 uint64_t result = (
static_cast<uint64_t
>(byte_buffer[0])) << 56;
115 result |= (
static_cast<uint64_t
>(byte_buffer[1])) << 48;
116 result |= (
static_cast<uint64_t
>(byte_buffer[2])) << 40;
117 result |= (
static_cast<uint64_t
>(byte_buffer[3])) << 32;
118 result |= (
static_cast<uint64_t
>(byte_buffer[4])) << 24;
119 result |= (
static_cast<uint64_t
>(byte_buffer[5])) << 16;
120 result |= (
static_cast<uint64_t
>(byte_buffer[6])) << 8;
121 result |= (
static_cast<uint64_t
>(byte_buffer[7]));
137 if (length <
sizeof(uint32_t)) {
139 "Length (" << length <<
") of buffer is insufficient " <<
140 "to write a uint32_t");
143 uint8_t* byte_buffer =
static_cast<uint8_t*
>(buffer);
145 byte_buffer[0] =
static_cast<uint8_t
>((value & 0xff000000U) >> 24);
146 byte_buffer[1] =
static_cast<uint8_t
>((value & 0x00ff0000U) >> 16);
147 byte_buffer[2] =
static_cast<uint8_t
>((value & 0x0000ff00U) >> 8);
148 byte_buffer[3] =
static_cast<uint8_t
>((value & 0x000000ffU));
150 return (byte_buffer +
sizeof(uint32_t));
156 #endif // IO_UTILITIES_H
uint8_t * writeUint32(uint32_t value, uint8_t *buffer, size_t length)
Write Unsigned 32-Bit Integer to Buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
uint8_t * writeUint16(uint16_t value, void *buffer, size_t length)
Write Unsigned 16-Bit Integer to Buffer.
uint32_t readUint32(const uint8_t *buffer, size_t length)
Read Unsigned 32-Bit Integer from Buffer.
Defines the logger used by the top-level component of kea-dhcp-ddns.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
uint64_t readUint64(const uint8_t *buffer, size_t length)
Read Unsigned 64-Bit Integer from Buffer.