#include <errno.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/debug.h>
-#include <freeradius-devel/util/net.h>
+#include <freeradius-devel/util/nbo.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
{ \
fr_assert(!out->is_const); \
_FR_DBUFF_EXTEND_LOWAT_POS_OR_RETURN(pos_p, out, sizeof(_type##_t)); \
- fr_net_from_##_type((*pos_p), num); \
+ fr_nbo_from_##_type((*pos_p), num); \
return _fr_dbuff_set(pos_p, out, (*pos_p) + sizeof(_type##_t)); \
}
FR_DBUFF_PARSE_INT_DEF(uint16)
static inline ssize_t _fr_dbuff_in_uint64v(uint8_t **pos_p, fr_dbuff_t *dbuff, uint64_t num)
{
size_t ret;
+ uint8_t swapped[sizeof(uint64_t)];
ret = ROUND_UP_DIV((size_t)fr_high_bit_pos(num | 0x08), 8);
- num = ntohll(num);
+ fr_nbo_from_uint64(swapped, num);
- return _fr_dbuff_in_memcpy(pos_p, dbuff, ((uint8_t *)&num) + (sizeof(uint64_t) - ret), ret);
+ return _fr_dbuff_in_memcpy(pos_p, dbuff, (swapped + (sizeof(uint64_t) - ret)), ret);
}
/** Copy an integer value into a dbuff or marker using our internal variable length encoding
{ \
fr_assert(out); \
FR_DBUFF_EXTEND_LOWAT_OR_RETURN(in, sizeof(_type##_t)); \
- *out = fr_net_to_##_type((*pos_p)); \
+ *out = fr_nbo_to_##_type((*pos_p)); \
return _fr_dbuff_set(pos_p, in, (*pos_p) + sizeof(_type##_t)); \
}
slen = _fr_dbuff_out_memcpy(((uint8_t *) num) + (8 - length), pos_p, dbuff, length);
if (slen <= 0) return slen;
- *num = fr_net_to_uint64((uint8_t const *)num);
+ *num = fr_nbo_to_uint64((uint8_t const *)num);
return length;
}
if (slen <= 0) return slen;
if (msb & 0x80) memset(((uint8_t *)num), 0xff, sizeof(*num) - length);
- *num = fr_net_to_int64((uint8_t const *)num);
+ *num = fr_nbo_to_int64((uint8_t const *)num);
return length;
}
*
* @note Passing constants to fr_dbuff_in() as it is written results in
* warnings about narrowing casts on the constants--but those casts are in
- * the underlying inlined fr_net_from*() functions. They have to be there;
+ * the underlying inlined fr_nbo_from*() functions. They have to be there;
* that's how those functions work. (The tests worked despite the warnings.)
* Using variables avoids the warnings, at least with the compile options
* the build system uses by default.
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/ext.h>
+#include <freeradius-devel/util/hash.h>
#include <limits.h>
--- /dev/null
+TARGET := dict.wasm
+
+SRC_CC := emcc
+SRC_CFLAGS := ''
+
+SOURCES := dict_ext.c \
+ dict_fixup.c \
+ dict_print.c \
+ dict_tokenize.c \
+ dict_unknown.c \
+ dict_util.c \
--- /dev/null
+#pragma once
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/** Structures and functions for converting integers to/from network byte order
+ *
+ * @file src/lib/util/nbo.h
+ *
+ * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
+ * @copyright 2022 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
+ */
+RCSIDH(nbo_h, "$Id$")
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <freeradius-devel/util/misc.h>
+
+/** Write out an unsigned 16bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_uint16(uint8_t out[static sizeof(uint16_t)], uint16_t num)
+{
+ out[0] = (num >> 8) & 0xff;
+ out[1] = num & 0xff;
+}
+
+/** Write out an unsigned 24bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_uint24(uint8_t out[static 3], uint32_t num)
+{
+ out[0] = (num >> 16) & 0xff;
+ out[1] = (num >> 8) & 0xff;
+ out[2] = num & 0xff;
+}
+
+/** Write out an unsigned 32bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_uint32(uint8_t out[static sizeof(uint32_t)], uint32_t num)
+{
+ fr_nbo_from_uint16(out, (uint16_t) (num >> 16));
+ fr_nbo_from_uint16(out + sizeof(uint16_t), (uint16_t) num);
+}
+
+/** Write out an unsigned 64bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_uint64(uint8_t out[static sizeof(uint64_t)], uint64_t num)
+{
+ fr_nbo_from_uint32(out, (uint32_t)(num >> 32));
+ fr_nbo_from_uint32(out + sizeof(uint32_t), (uint32_t)num);
+}
+
+/** Write out an signed 16bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_int16(uint8_t out[static sizeof(int16_t)], int16_t num)
+{
+ out[0] = (num >> 8) & 0xff;
+ out[1] = num & 0xff;
+}
+
+/** Write out an signed 32bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_int32(uint8_t out[static sizeof(int32_t)], int32_t num)
+{
+ fr_nbo_from_uint16(out, (int16_t) (num >> 16));
+ fr_nbo_from_uint16(out + sizeof(int16_t), (int16_t) num);
+}
+
+/** Write out an signed 64bit integer in wire format (big endian)
+ *
+ * @param[out] out Where to write the integer.
+ * @param[in] num to encode.
+ */
+static inline void fr_nbo_from_int64(uint8_t out[static sizeof(uint64_t)], uint64_t num)
+{
+ fr_nbo_from_uint32(out, (int32_t)(num >> 32));
+ fr_nbo_from_uint32(out + sizeof(int32_t), (int32_t)num);
+}
+
+/** Write out an unsigned 64bit integer in wire format using the fewest bytes possible
+ *
+ * @param[out] out Where to write big endian encoding of num.
+ * Should be at least 8 bytes.
+ * @param[in] num Number to encode.
+ * @return the number of bytes written to out.
+ */
+static inline size_t fr_nbo_from_uint64v(uint8_t out[static sizeof(uint64_t)], uint64_t num)
+{
+ size_t ret;
+ uint8_t swapped[sizeof(uint64_t)];
+
+ ret = ROUND_UP_DIV((size_t)fr_high_bit_pos(num | 0x80), 8);
+
+ fr_nbo_from_uint64(swapped, num);
+ memcpy(out, (swapped + (sizeof(uint64_t) - ret)), ret); /* aligned */
+
+ return ret;
+}
+
+/** Read an unsigned 16bit integer from wire format (big endian)
+ *
+ * @param[in] data To convert to a 16bit unsigned integer of native endianness.
+ * @return a 16 bit unsigned integer of native endianness.
+ */
+static inline uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
+{
+ return (((uint16_t)data[0]) << 8) | data[1];
+}
+
+/** Read an unsigned 24bit integer from wire format (big endian)
+ *
+ * @param[in] data To convert to a 24bit unsigned integer of native endianness.
+ * @return a 24 bit unsigned integer of native endianness.
+ */
+static inline uint32_t fr_nbo_to_uint24(uint8_t const data[static 3])
+{
+ return (((uint32_t)data[0]) << 16) | (((uint32_t)data[1]) << 8) | data[2];
+}
+
+/** Read an unsigned 32bit integer from wire format (big endian)
+ *
+ * @param[in] data To convert to a 32bit unsigned integer of native endianness.
+ * @return a 32 bit unsigned integer of native endianness.
+ */
+static inline uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
+{
+ return ((uint32_t)fr_nbo_to_uint16(data) << 16) | fr_nbo_to_uint16(data + sizeof(uint16_t));
+}
+
+/** Read an unsigned 64bit integer from wire format (big endian)
+ *
+ * @param[in] data To convert to a 64bit unsigned integer of native endianness.
+ * @return a 64 bit unsigned integer of native endianness.
+ */
+static inline uint64_t fr_nbo_to_uint64(uint8_t const data[static sizeof(uint64_t)])
+{
+ return ((uint64_t)fr_nbo_to_uint32(data) << 32) | fr_nbo_to_uint32(data + sizeof(uint32_t));
+}
+
+/*
+ * To get signed integers, simply cast.
+ */
+#define fr_nbo_to_int16(_x) ((int16_t) fr_nbo_to_uint16(_x))
+#define fr_nbo_to_int32(_x) ((int32_t) fr_nbo_to_uint32(_x))
+#define fr_nbo_to_int64(_x) ((int64_t) fr_nbo_to_uint64(_x))
+
+
+/** Read an unsigned 64bit integer from wire format (big endian) with a variable length encoding
+ *
+ * @param[in] data Buffer containing the number.
+ * @param[in] data_len Length of number.
+ * @return a 64 bit unsigned integer of native endianness.
+ */
+static inline uint64_t fr_nbo_to_uint64v(uint8_t const *data, size_t data_len)
+{
+ uint64_t num = 0;
+ uint64_t nbo;
+
+ if (unlikely(data_len > sizeof(uint64_t))) return 0;
+
+ /*
+ * Copy at an offset into memory
+ * allocated for the uin64_t
+ */
+ memcpy(((uint8_t *)&num) + (sizeof(uint64_t) - data_len), data, data_len); /* aligned */
+ fr_nbo_from_uint64((uint8_t *)&nbo, num);
+
+ return nbo;
+}
+
+static inline uint64_t fr_nbo_to_int64v(uint8_t const *data, size_t data_len)
+{
+ int64_t num = 0;
+ uint64_t nbo;
+
+ if (unlikely(data_len > sizeof(uint64_t))) return 0;
+
+ /*
+ * Copy at an offset into memory
+ * allocated for the uin64_t
+ */
+ memcpy(((uint8_t *)&num) + (sizeof(uint64_t) - data_len), data, data_len); /* aligned */
+ if (*data & 0x80) memset(((uint8_t *)&num) + data_len, 0xff, sizeof(num) - data_len);
+
+ fr_nbo_from_uint64((uint8_t *)&nbo, num);
+
+ return nbo;
+}
+
+/** Convert bits (as in prefix length) to bytes, rounding up.
+ *
+ * @param bits number of bits in the prefix
+ * @return number of bytes taken to store the prefix
+ */
+static inline unsigned int fr_bytes_from_bits(unsigned int bits)
+{
+ return (bits + 7) >> 3;
+}
+
+#ifdef __cplusplus
+}
+#endif
uint16_t fr_ip_header_checksum(uint8_t const *data, uint8_t ihl);
uint16_t fr_ip6_pesudo_header_checksum(struct in6_addr const *src, struct in6_addr const *dst, uint16_t ip_len, uint8_t ip_next);
-/** Write out an unsigned 16bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_uint16(uint8_t out[static sizeof(uint16_t)], uint16_t num)
-{
- out[0] = (num >> 8) & 0xff;
- out[1] = num & 0xff;
-}
-
-/** Write out an unsigned 24bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_uint24(uint8_t out[static 3], uint32_t num)
-{
- out[0] = (num >> 16) & 0xff;
- out[1] = (num >> 8) & 0xff;
- out[2] = num & 0xff;
-}
-
-/** Write out an unsigned 32bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_uint32(uint8_t out[static sizeof(uint32_t)], uint32_t num)
-{
- fr_net_from_uint16(out, (uint16_t) (num >> 16));
- fr_net_from_uint16(out + sizeof(uint16_t), (uint16_t) num);
-}
-
-/** Write out an unsigned 64bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_uint64(uint8_t out[static sizeof(uint64_t)], uint64_t num)
-{
- fr_net_from_uint32(out, (uint32_t)(num >> 32));
- fr_net_from_uint32(out + sizeof(uint32_t), (uint32_t)num);
-}
-
-/** Write out an signed 16bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_int16(uint8_t out[static sizeof(int16_t)], int16_t num)
-{
- out[0] = (num >> 8) & 0xff;
- out[1] = num & 0xff;
-}
-
-/** Write out an signed 32bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_int32(uint8_t out[static sizeof(int32_t)], int32_t num)
-{
- fr_net_from_uint16(out, (int16_t) (num >> 16));
- fr_net_from_uint16(out + sizeof(int16_t), (int16_t) num);
-}
-
-/** Write out an signed 64bit integer in wire format (big endian)
- *
- * @param[out] out Where to write the integer.
- * @param[in] num to encode.
- */
-static inline void fr_net_from_int64(uint8_t out[static sizeof(uint64_t)], uint64_t num)
-{
- fr_net_from_uint32(out, (int32_t)(num >> 32));
- fr_net_from_uint32(out + sizeof(int32_t), (int32_t)num);
-}
-
-/** Write out an unsigned 64bit integer in wire format using the fewest bytes possible
- *
- * @param[out] out Where to write big endian encoding of num.
- * Should be at least 8 bytes.
- * @param[in] num Number to encode.
- * @return the number of bytes written to out.
- */
-static inline size_t fr_net_from_uint64v(uint8_t out[static sizeof(uint64_t)], uint64_t num)
-{
- size_t ret;
-
- ret = ROUND_UP_DIV((size_t)fr_high_bit_pos(num | 0x80), 8);
- num = ntohll(num);
- memcpy(out, ((uint8_t *)&num) + (sizeof(uint64_t) - ret), ret); /* aligned */
-
- return ret;
-}
-
-/** Read an unsigned 16bit integer from wire format (big endian)
- *
- * @param[in] data To convert to a 16bit unsigned integer of native endianness.
- * @return a 16 bit unsigned integer of native endianness.
- */
-static inline uint16_t fr_net_to_uint16(uint8_t const data[static sizeof(uint16_t)])
-{
- return (((uint16_t)data[0]) << 8) | data[1];
-}
-
-/** Read an unsigned 24bit integer from wire format (big endian)
- *
- * @param[in] data To convert to a 24bit unsigned integer of native endianness.
- * @return a 24 bit unsigned integer of native endianness.
- */
-static inline uint32_t fr_net_to_uint24(uint8_t const data[static 3])
-{
- return (((uint32_t)data[0]) << 16) | (((uint32_t)data[1]) << 8) | data[2];
-}
-
-/** Read an unsigned 32bit integer from wire format (big endian)
- *
- * @param[in] data To convert to a 32bit unsigned integer of native endianness.
- * @return a 32 bit unsigned integer of native endianness.
- */
-static inline uint32_t fr_net_to_uint32(uint8_t const data[static sizeof(uint32_t)])
-{
- return ((uint32_t)fr_net_to_uint16(data) << 16) | fr_net_to_uint16(data + sizeof(uint16_t));
-}
-
-/** Read an unsigned 64bit integer from wire format (big endian)
- *
- * @param[in] data To convert to a 64bit unsigned integer of native endianness.
- * @return a 64 bit unsigned integer of native endianness.
- */
-static inline uint64_t fr_net_to_uint64(uint8_t const data[static sizeof(uint64_t)])
-{
- return ((uint64_t)fr_net_to_uint32(data) << 32) | fr_net_to_uint32(data + sizeof(uint32_t));
-}
-
-/*
- * To get signed integers, simply cast.
- */
-#define fr_net_to_int16(_x) ((int16_t) fr_net_to_uint16(_x))
-#define fr_net_to_int32(_x) ((int32_t) fr_net_to_uint32(_x))
-#define fr_net_to_int64(_x) ((int64_t) fr_net_to_uint64(_x))
-
-
-/** Read an unsigned 64bit integer from wire format (big endian) with a variable length encoding
- *
- * @param[in] data Buffer containing the number.
- * @param[in] data_len Length of number.
- * @return a 64 bit unsigned integer of native endianness.
- */
-static inline uint64_t fr_net_to_uint64v(uint8_t const *data, size_t data_len)
-{
- uint64_t num = 0;
-
- if (unlikely(data_len > sizeof(uint64_t))) return 0;
-
- /*
- * Copy at an offset into memory
- * allocated for the uin64_t
- */
- memcpy(((uint8_t *)&num) + (sizeof(uint64_t) - data_len), data, data_len); /* aligned */
- return ntohll(num);
-}
-
-static inline uint64_t fr_net_to_int64v(uint8_t const *data, size_t data_len)
-{
- int64_t num = 0;
-
- if (unlikely(data_len > sizeof(uint64_t))) return 0;
-
- /*
- * Copy at an offset into memory
- * allocated for the uin64_t
- */
- memcpy(((uint8_t *)&num) + (sizeof(uint64_t) - data_len), data, data_len); /* aligned */
-
- if (*data & 0x80) memset(((uint8_t *)&num) + data_len, 0xff, sizeof(num) - data_len);
-
- return ntohll(num);
-}
-
-/** Convert bits (as in prefix length) to bytes, rounding up.
- *
- * @param bits number of bits in the prefix
- * @return number of bytes taken to store the prefix
- */
-static inline unsigned int fr_bytes_from_bits(unsigned int bits)
-{
- return (bits + 7) >> 3;
-}
-
#ifdef __cplusplus
}
#endif
case FR_TYPE_UINT64: {
uint8_t array[8];
- fr_net_from_uint64(array, src->vb_uint64);
+ fr_nbo_from_uint64(array, src->vb_uint64);
/*
* For OUIs in the DB.
}
fr_value_box_init(dst, dst_type, dst_enumv, src->tainted);
- dst->vb_uint64 = fr_net_to_uint64(&src->vb_ifid[0]);
+ dst->vb_uint64 = fr_nbo_to_uint64(&src->vb_ifid[0]);
return 0;
}
* proto_dns sets the priority
*/
- xid = fr_net_to_uint16(buffer);
+ xid = fr_nbo_to_uint16(buffer);
/*
* Print out what we received.
uint16_t len;
fr_pair_t *vp;
- attr = fr_net_to_uint16(p) & EAP_FAST_TLV_TYPE;
+ attr = fr_nbo_to_uint16(p) & EAP_FAST_TLV_TYPE;
p += 2;
- len = fr_net_to_uint16(p);
+ len = fr_nbo_to_uint16(p);
p += 2;
da = fr_dict_attr_child_by_num(parent, attr);
RDEBUG3("%04zu %02x%02x%02x%02x %02x%02x%02x%02x ...", p - data,
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- attr = fr_net_to_uint32(p);
+ attr = fr_nbo_to_uint32(p);
p += 4;
flags = p[0];
p++;
- value_len = fr_net_to_uint64v(p, 3); /* Yes, that is a 24 bit length field */
+ value_len = fr_nbo_to_uint64v(p, 3); /* Yes, that is a 24 bit length field */
p += 3;
if (value_len < 8) {
* Do we have a vendor field?
*/
if (flags & FR_DIAMETER_AVP_FLAG_VENDOR) {
- vendor = fr_net_to_uint32(p);
+ vendor = fr_nbo_to_uint32(p);
p += 4;
value_len -= 4; /* -= 4 for the vendor ID field */
p = data;
end = data + data_len;
while (p < end) {
- sum += fr_net_to_uint16(p); /* type / code */
+ sum += fr_nbo_to_uint16(p); /* type / code */
p += 2;
}
#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/log.h>
+#include <freeradius-devel/util/net.h>
#include <freeradius-devel/protocol/arp/dictionary.h>
#include <freeradius-devel/protocol/arp/rfc826.h>
if (data_len != 8) goto raw;
- ipaddr = fr_net_to_uint32(p);
- mask = fr_net_to_uint32(p + 4);
+ ipaddr = fr_nbo_to_uint32(p);
+ mask = fr_nbo_to_uint32(p + 4);
p += 8;
/*
mask <<= (32 - vp->vp_ip.prefix);
if (*p > 24) {
- ipaddr = fr_net_to_uint32(p + 1);
+ ipaddr = fr_nbo_to_uint32(p + 1);
} else if (*p > 16) {
- ipaddr = fr_net_to_uint24(p + 1);
+ ipaddr = fr_nbo_to_uint24(p + 1);
ipaddr <<= 8;
} else if (*p > 8) {
- ipaddr = fr_net_to_uint16(p + 1);
+ ipaddr = fr_nbo_to_uint16(p + 1);
ipaddr <<= 16;
} else { /* 1..8 */
return data_len + 2; /* decoded the whole thing */
}
- pen = fr_net_to_uint32(p);
+ pen = fr_nbo_to_uint32(p);
/*
* Verify that the parent (which should be a VSA)
switch (packet[0]) {
case FR_PACKET_TYPE_VALUE_ADVERTISE:
- transaction_id = fr_net_to_uint24(&packet[1]);
+ transaction_id = fr_nbo_to_uint24(&packet[1]);
if (transaction_id != packet_ctx->transaction_id) {
fail_tid:
fr_strerror_const("Transaction ID does not match");
return true;
case FR_PACKET_TYPE_VALUE_REPLY:
- transaction_id = fr_net_to_uint24(&packet[1]);
+ transaction_id = fr_nbo_to_uint24(&packet[1]);
if (transaction_id != packet_ctx->transaction_id) goto fail_tid;
if (!fr_dhcpv6_option_find(options, end, FR_SERVER_ID)) goto fail_sid;
return verify_to_client(option + 4, DHCPV6_GET_OPTION_LEN(option), packet_ctx);
case FR_DHCPV6_LEASE_QUERY_REPLY:
- transaction_id = fr_net_to_uint24(&packet[1]);
+ transaction_id = fr_nbo_to_uint24(&packet[1]);
if (transaction_id != packet_ctx->transaction_id) goto fail_tid;
if (!fr_dhcpv6_option_find(options, end, FR_SERVER_ID)) goto fail_sid;
FR_DBUFF_IN_MEMCPY_RETURN(&frame_dbuff, vp->vp_octets, DHCPV6_TRANSACTION_ID_LEN);
} else {
uint8_t id[DHCPV6_TRANSACTION_ID_LEN];
- fr_net_from_uint24(id, fr_rand());
+ fr_nbo_from_uint24(id, fr_rand());
FR_DBUFF_IN_MEMCPY_RETURN(&frame_dbuff, id, sizeof(id)); /* Need 24 bits of the 32bit integer */
}
break;
break;
}
- length = fr_net_to_uint16(option + 2);
+ length = fr_nbo_to_uint16(option + 2);
fprintf(fp, "%.*s", depth + 1, tabs);
- fprintf(fp, "%04x %04x\t", fr_net_to_uint16(option), length);
+ fprintf(fp, "%04x %04x\t", fr_nbo_to_uint16(option), length);
if ((option + 4 + length) > end) {
print_hex_data(fp, option + 4, end - (option + 4), depth + 3);
while (p < end) {
if ((end - p) < 2) goto raw;
- element_len = fr_net_to_uint16(p);
+ element_len = fr_nbo_to_uint16(p);
if ((size_t) (end - p) < (((size_t) element_len) + 2)) goto raw;
#define DHCPV6_RELAY_HDR_LEN (DHCPV6_MSG_TYPE_LEN + DHCPV6_HOP_COUNT_LEN + DHCPV6_LINK_ADDRESS_LEN + DHCPV6_PEER_ADDRESS_LEN)
#define DHCPV6_OPT_HDR_LEN (sizeof(uint16_t) * 2)
-#define DHCPV6_GET_OPTION_NUM(_x) fr_net_to_uint16(_x)
-#define DHCPV6_GET_OPTION_LEN(_x) fr_net_to_uint16((_x) + 2)
+#define DHCPV6_GET_OPTION_NUM(_x) fr_nbo_to_uint16(_x)
+#define DHCPV6_GET_OPTION_LEN(_x) fr_nbo_to_uint16((_x) + 2)
#define DHCPV6_MAX_RELAY_NESTING 10
return false;
}
- len = fr_net_to_uint16(p + 2);
+ len = fr_nbo_to_uint16(p + 2);
if ((p + 4 + len) > end) {
DECODE_FAIL(TLV_OVERFLOWS_RR);
return false;
return false;
}
- qdcount = fr_net_to_uint16(packet + 4);
+ qdcount = fr_nbo_to_uint16(packet + 4);
if (query) {
/*
DECODE_FAIL(NO_QUESTIONS);
return false;
}
- if (fr_net_to_uint16(packet + 6) != 0) {
+ if (fr_nbo_to_uint16(packet + 6) != 0) {
DECODE_FAIL(NS_IN_QUESTION);
return false;
}
- if (fr_net_to_uint16(packet + 8) != 0) {
+ if (fr_nbo_to_uint16(packet + 8) != 0) {
DECODE_FAIL(ANSWERS_IN_QUESTION);
return false;
}
*/
}
- expected = fr_net_to_uint16(packet + 4) + fr_net_to_uint16(packet + 6) + fr_net_to_uint16(packet + 8) + fr_net_to_uint16(packet + 10);
+ expected = fr_nbo_to_uint16(packet + 4) + fr_nbo_to_uint16(packet + 6) + fr_nbo_to_uint16(packet + 8) + fr_nbo_to_uint16(packet + 10);
count = 0;
p = packet + DNS_HDR_LEN;
return false;
}
- len = fr_net_to_uint16(p);
+ len = fr_nbo_to_uint16(p);
if (len == 0) {
DECODE_FAIL(ZERO_RR_LEN);
return false;
break;
}
- element_len = fr_net_to_uint16(p);
+ element_len = fr_nbo_to_uint16(p);
if ((p + 2 + element_len) > end) {
goto raw;
}
}
-#define DNS_GET_OPTION_NUM(_x) fr_net_to_uint16(_x)
-#define DNS_GET_OPTION_LEN(_x) fr_net_to_uint16((_x) + 2)
+#define DNS_GET_OPTION_NUM(_x) fr_nbo_to_uint16(_x)
+#define DNS_GET_OPTION_LEN(_x) fr_nbo_to_uint16((_x) + 2)
static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
fr_dict_attr_t const *parent,
int i, count;
uint8_t const *p = rr;
- count = fr_net_to_uint16(counter);
+ count = fr_nbo_to_uint16(counter);
FR_PROTO_TRACE("Decoding %u of %s", count, attr->name);
for (i = 0; i < count; i++) {
ssize_t slen;
if (!vp) break;
}
- fr_net_from_uint16(counter, count);
+ fr_nbo_from_uint16(counter, count);
FR_PROTO_TRACE(" %s encoded %d records", attr->name, count);
return fr_dbuff_set(dbuff, &work_dbuff);
* the function.
*/
vlen = fr_dbuff_used(&value_dbuff);
- flen = (ssize_t) fr_net_from_uint64v(buff, vlen);
+ flen = (ssize_t) fr_nbo_from_uint64v(buff, vlen);
/*
* Ugh, it's a long one, need to move the data.
end = (data + data_len);
/* Opcode */
- opcode = fr_net_to_uint16(p);
+ opcode = fr_nbo_to_uint16(p);
vp = fr_pair_afrom_da(ctx, attr_tftp_opcode);
if (!vp) goto error;
vp = fr_pair_afrom_da(ctx, attr_tftp_block);
if (!vp) goto error;
- vp->vp_uint16 = fr_net_to_uint16(p);
+ vp->vp_uint16 = fr_nbo_to_uint16(p);
fr_pair_append(out, vp);
vp = fr_pair_afrom_da(ctx, attr_tftp_error_code);
if (!vp) goto error;
- vp->vp_uint16 = fr_net_to_uint16(p);
+ vp->vp_uint16 = fr_nbo_to_uint16(p);
fr_pair_append(out, vp);