26 RCSID(
"$Id: e8695b051da97b131601c6bb93906ae1577d2440 $")
80 {
L(
"dns_label"), { .func = dict_flag_dns_label } },
81 {
L(
"dns_label_uncompressed"), { .func = dict_flag_dns_label_uncompressed } }
84 #define DECODE_FAIL(_reason) if (reason) *reason = FR_DNS_DECODE_FAIL_ ## _reason
97 if ((p + 4 + len) > end) {
111 int qdcount,
count, expected;
118 if (packet_len > 65535) {
126 if (((packet[2] & 0x80) == 0) != query) {
167 end = packet + packet_len;
179 memset(
fr_dns_marker, 0, packet_len < (1 << 14) ? packet_len : (1 << 14));
186 if (p + (qdcount * 5) > end) {
192 if ((p + ((expected - qdcount) * (1 + 8 + 2))) > end) {
241 offset += ((*p & ~0xc0) << 8);
254 if (offset >= (start - packet)) {
282 if ((p + *p + 1) > end) {
333 is_opt = (p[0] == 0) && (p[1] == 41);
345 if (!is_opt && (len == 0)) {
351 if ((p + len) > end) {
368 if (
count > expected) {
374 if (
count != expected) {
392 lb->
end = packet + packet_len;
400 memset(lb->
mark, 0, packet_len);
450 da->flags.is_known_width =
true;
455 fr_strerror_const(
"The 'dns_label' flag can only be used with attributes of type 'string'");
458 da->flags.is_known_width =
true;
467 .default_type_size = 2,
468 .default_type_length = 2,
#define L(_str)
Helper for initialising arrays of string literals.
#define fr_dict_autofree(_to_free)
fr_dict_attr_t const ** out
Where to write a pointer to the resolved fr_dict_attr_t.
fr_dict_t const ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
Process a dict_attr_autoload element to load/verify a dictionary attribute.
#define fr_dict_autoload(_to_load)
char const * name
name of this protocol
#define FR_DICT_ATTR_FLAG_FUNC(_struct, _name)
Define a flag setting function, which sets one bit in a fr_dict_attr_flags_t.
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
Protocol specific custom flag definitnion.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
uint8_t const * start
start of packet
uint8_t const * end
end of the packet
fr_dns_block_t * blocks
maximum number of labels
uint8_t * mark
markup buffer used for decoding.
int num
number of used labels
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_OCTETS
Raw octets.
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)
#define DECODE_FAIL(_reason)
fr_dict_attr_autoload_t dns_dict_attr[]
int fr_dns_global_init(void)
Resolve/cache attributes in the DNS dictionary.
fr_dict_protocol_t libfreeradius_dns_dict_protocol
static _Thread_local fr_dns_block_t fr_dns_blocks[256]
fr_dict_attr_t const * attr_dns_ns
static _Thread_local fr_dns_labels_t fr_dns_labels
static _Thread_local uint8_t fr_dns_marker[65536]
static uint32_t instance_count
static bool attr_valid(fr_dict_attr_t *da)
fr_dict_attr_t const * attr_dns_packet
void fr_dns_global_free(void)
fr_dict_attr_t const * attr_dns_question
fr_dict_autoload_t dns_dict[]
fr_dns_labels_t * fr_dns_labels_get(uint8_t const *packet, size_t packet_len, bool init_mark)
fr_dict_attr_t const * attr_dns_ar
fr_dict_attr_t const * attr_dns_rr
char const * fr_dns_packet_names[FR_DNS_CODE_MAX]
static fr_dict_flag_parser_t const dns_flags[]
static bool fr_dns_tlv_ok(uint8_t const *p, uint8_t const *end, fr_dns_decode_fail_t *reason)
fr_dict_t const * dict_dns
bool fr_dns_packet_ok(uint8_t const *packet, size_t packet_len, bool query, fr_dns_decode_fail_t *reason)
static bool fr_dns_flag_dns_label_any(fr_dict_attr_t const *da)
@ FR_DNS_STATEFUL_OPERATION
#define fr_strerror_const(_msg)