26 RCSID(
"$Id: 567634561b4b0574a3debb0b718d84ca6f943e07 $")
76 #define DECODE_FAIL(_reason) if (reason) *reason = FR_DNS_DECODE_FAIL_ ## _reason
89 if ((p + 4 + len) > end) {
103 int qdcount,
count, expected;
110 if (packet_len > 65535) {
118 if (((packet[2] & 0x80) == 0) != query) {
159 end = packet + packet_len;
171 memset(
fr_dns_marker, 0, packet_len < (1 << 14) ? packet_len : (1 << 14));
178 if (p + (qdcount * 5) > end) {
184 if ((p + ((expected - qdcount) * (1 + 8 + 2))) > end) {
233 offset += ((*p & ~0xc0) << 8);
246 if (offset >= (start - packet)) {
274 if ((p + *p + 1) > end) {
325 is_opt = (p[0] == 0) && (p[1] == 41);
337 if (!is_opt && (len == 0)) {
343 if ((p + len) > end) {
360 if (
count > expected) {
366 if (
count != expected) {
384 lb->
end = packet + packet_len;
392 memset(lb->
mark, 0, packet_len);
459 fr_strerror_const(
"The 'dns_label' flag can only be used with attributes of type 'string'");
471 .default_type_size = 2,
472 .default_type_length = 2,
#define L(_str)
Helper for initialising arrays of string literals.
@ FLAG_ENCODE_DNS_LABEL
encode as DNS label
#define fr_dict_autofree(_to_free)
unsigned int array
Pack multiples into 1 attr.
unsigned int extra
really "subtype is used by dict, not by protocol"
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)
unsigned int is_known_width
is treated as if it has a known width for structs
char const * name
name of this protocol
uint8_t subtype
protocol-specific values, OR key fields
Specifies an attribute which must be present for the module to function.
Values of the encryption flags.
Specifies a dictionary which must be loaded/loadable for the module to function.
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
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 bool attr_valid(UNUSED fr_dict_t *dict, UNUSED fr_dict_attr_t const *parent, UNUSED char const *name, UNUSED int attr, fr_type_t type, fr_dict_attr_flags_t *flags)
static bool fr_dns_tlv_ok(uint8_t const *p, uint8_t const *end, fr_dns_decode_fail_t *reason)
static fr_table_num_ordered_t const subtype_table[]
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)
@ FR_DNS_STATEFUL_OPERATION
@ FLAG_ENCODE_DNS_LABEL_UNCOMPRESSED
encode as uncompressed DNS label
fr_aka_sim_id_type_t type
An element in an arbitrarily ordered array of name to num mappings.
#define fr_strerror_const(_msg)