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(uint32_t)) {
108 "Length (" << length <<
") of buffer is insufficient " <<
109 "to write a uint32_t");
112 uint8_t* byte_buffer =
static_cast<uint8_t*
>(buffer);
114 byte_buffer[0] =
static_cast<uint8_t
>((value & 0xff000000U) >> 24);
115 byte_buffer[1] =
static_cast<uint8_t
>((value & 0x00ff0000U) >> 16);
116 byte_buffer[2] =
static_cast<uint8_t
>((value & 0x0000ff00U) >> 8);
117 byte_buffer[3] =
static_cast<uint8_t
>((value & 0x000000ffU));
119 return (byte_buffer +
sizeof(uint32_t));
132 if (length <
sizeof(uint64_t)) {
134 "Length (" << length <<
") of buffer is insufficient " <<
135 "to read a uint64_t");
138 const uint8_t* byte_buffer =
static_cast<const uint8_t*
>(buffer);
140 uint64_t result = (
static_cast<uint64_t
>(byte_buffer[0])) << 56;
141 result |= (
static_cast<uint64_t
>(byte_buffer[1])) << 48;
142 result |= (
static_cast<uint64_t
>(byte_buffer[2])) << 40;
143 result |= (
static_cast<uint64_t
>(byte_buffer[3])) << 32;
144 result |= (
static_cast<uint64_t
>(byte_buffer[4])) << 24;
145 result |= (
static_cast<uint64_t
>(byte_buffer[5])) << 16;
146 result |= (
static_cast<uint64_t
>(byte_buffer[6])) << 8;
147 result |= (
static_cast<uint64_t
>(byte_buffer[7]));
162 if (length <
sizeof(uint64_t)) {
164 "Length (" << length <<
") of buffer is insufficient " <<
165 "to write a uint64_t");
168 uint8_t* byte_buffer =
static_cast<uint8_t*
>(buffer);
170 byte_buffer[0] =
static_cast<uint8_t
>((value & 0xff00000000000000UL) >> 56);
171 byte_buffer[1] =
static_cast<uint8_t
>((value & 0x00ff000000000000UL) >> 48);
172 byte_buffer[2] =
static_cast<uint8_t
>((value & 0x0000ff0000000000UL) >> 40);
173 byte_buffer[3] =
static_cast<uint8_t
>((value & 0x000000ff00000000UL) >> 32);
174 byte_buffer[4] =
static_cast<uint8_t
>((value & 0x00000000ff000000UL) >> 24);
175 byte_buffer[5] =
static_cast<uint8_t
>((value & 0x0000000000ff0000UL) >> 16);
176 byte_buffer[6] =
static_cast<uint8_t
>((value & 0x000000000000ff00UL) >> 8);
177 byte_buffer[7] =
static_cast<uint8_t
>((value & 0x00000000000000ffUL));
179 return (byte_buffer +
sizeof(uint64_t));
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
#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.
uint8_t * writeUint32(uint32_t value, void *buffer, size_t length)
Write Unsigned 32-Bit Integer to Buffer.
uint32_t readUint32(const void *buffer, size_t length)
Read Unsigned 32-Bit Integer from Buffer.
uint64_t readUint64(const void *buffer, size_t length)
Read Unsigned 64-Bit Integer from Buffer.
uint8_t * writeUint64(uint64_t value, void *buffer, size_t length)
Write Unsigned 64-Bit Integer to Buffer.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
Defines the logger used by the top-level component of kea-lfc.