The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
base.c File Reference

Functions to send/receive dns packets. More...

#include "dns.h"
#include "attrs.h"
+ Include dependency graph for base.c:

Go to the source code of this file.

Data Structures

struct  dns_option_t
 

Macros

#define DECODE_FAIL(_reason)   if (reason) *reason = FR_DNS_DECODE_FAIL_ ## _reason
 

Functions

static bool attr_valid (fr_dict_attr_t *da)
 
void fr_dns_global_free (void)
 
int fr_dns_global_init (void)
 Resolve/cache attributes in the DNS dictionary. More...
 
fr_dns_labels_tfr_dns_labels_get (uint8_t const *packet, size_t packet_len, bool init_mark)
 
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_tlv_ok (uint8_t const *p, uint8_t const *end, fr_dns_decode_fail_t *reason)
 

Variables

fr_dict_attr_t const * attr_dns_ar
 
fr_dict_attr_t const * attr_dns_ns
 
fr_dict_attr_t const * attr_dns_packet
 
fr_dict_attr_t const * attr_dns_question
 
fr_dict_attr_t const * attr_dns_rr
 
fr_dict_t const * dict_dns
 
fr_dict_autoload_t dns_dict []
 
fr_dict_attr_autoload_t dns_dict_attr []
 
static fr_dict_flag_parser_t const dns_flags []
 
static _Thread_local fr_dns_block_t fr_dns_blocks [256]
 
static _Thread_local fr_dns_labels_t fr_dns_labels
 
static _Thread_local uint8_t fr_dns_marker [65536]
 
char const * fr_dns_packet_names [FR_DNS_CODE_MAX]
 
static uint32_t instance_count = 0
 
fr_dict_protocol_t libfreeradius_dns_dict_protocol
 

Detailed Description

Functions to send/receive dns packets.

Id
e8695b051da97b131601c6bb93906ae1577d2440

Definition in file base.c.


Data Structure Documentation

◆ dns_option_t

struct dns_option_t

Definition at line 33 of file base.c.

Data Fields
uint16_t code
uint16_t length

Macro Definition Documentation

◆ DECODE_FAIL

#define DECODE_FAIL (   _reason)    if (reason) *reason = FR_DNS_DECODE_FAIL_ ## _reason

Definition at line 84 of file base.c.

Function Documentation

◆ attr_valid()

static bool attr_valid ( fr_dict_attr_t da)
static

Definition at line 443 of file base.c.

+ Here is the call graph for this function:

◆ fr_dns_global_free()

void fr_dns_global_free ( void  )

Definition at line 434 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_global_init()

int fr_dns_global_init ( void  )

Resolve/cache attributes in the DNS dictionary.

Returns
  • 0 on success.
  • -1 on failure.

Definition at line 412 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_labels_get()

fr_dns_labels_t* fr_dns_labels_get ( uint8_t const *  packet,
size_t  packet_len,
bool  init_mark 
)

Definition at line 383 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_packet_ok()

bool fr_dns_packet_ok ( uint8_t const *  packet,
size_t  packet_len,
bool  query,
fr_dns_decode_fail_t reason 
)

Definition at line 108 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_tlv_ok()

static bool fr_dns_tlv_ok ( uint8_t const *  p,
uint8_t const *  end,
fr_dns_decode_fail_t reason 
)
static

Definition at line 86 of file base.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ attr_dns_ar

fr_dict_attr_t const* attr_dns_ar

Definition at line 55 of file base.c.

◆ attr_dns_ns

fr_dict_attr_t const* attr_dns_ns

Definition at line 54 of file base.c.

◆ attr_dns_packet

fr_dict_attr_t const* attr_dns_packet

Definition at line 51 of file base.c.

◆ attr_dns_question

fr_dict_attr_t const* attr_dns_question

Definition at line 52 of file base.c.

◆ attr_dns_rr

fr_dict_attr_t const* attr_dns_rr

Definition at line 53 of file base.c.

◆ dict_dns

fr_dict_t const* dict_dns

Definition at line 38 of file base.c.

◆ dns_dict

Initial value:
= {
{ .out = &dict_dns, .proto = "dns" },
{ NULL }
}
fr_dict_t const * dict_dns
Definition: base.c:38

Definition at line 45 of file base.c.

◆ dns_dict_attr

fr_dict_attr_autoload_t dns_dict_attr
Initial value:
= {
{ .out = &attr_dns_packet, .name = "Header", .type = FR_TYPE_STRUCT, .dict = &dict_dns },
{ .out = &attr_dns_question, .name = "Question", .type = FR_TYPE_STRUCT, .dict = &dict_dns },
{ .out = &attr_dns_rr, .name = "Resource-Record", .type = FR_TYPE_STRUCT, .dict = &dict_dns },
{ .out = &attr_dns_ns, .name = "Name-Server", .type = FR_TYPE_STRUCT, .dict = &dict_dns },
{ .out = &attr_dns_ar, .name = "Additional-Record", .type = FR_TYPE_STRUCT, .dict = &dict_dns },
{ NULL }
}
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
Definition: merged_model.c:119
fr_dict_attr_t const * attr_dns_ns
Definition: base.c:54
fr_dict_attr_t const * attr_dns_packet
Definition: base.c:51
fr_dict_attr_t const * attr_dns_question
Definition: base.c:52
fr_dict_attr_t const * attr_dns_ar
Definition: base.c:55
fr_dict_attr_t const * attr_dns_rr
Definition: base.c:53

Definition at line 58 of file base.c.

◆ dns_flags

fr_dict_flag_parser_t const dns_flags[]
static
Initial value:
= {
{ L("dns_label"), { .func = dict_flag_dns_label } },
{ L("dns_label_uncompressed"), { .func = dict_flag_dns_label_uncompressed } }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition: build.h:207

Definition at line 79 of file base.c.

◆ fr_dns_blocks

_Thread_local fr_dns_block_t fr_dns_blocks[256]
static

Definition at line 41 of file base.c.

◆ fr_dns_labels

_Thread_local fr_dns_labels_t fr_dns_labels
static

Definition at line 40 of file base.c.

◆ fr_dns_marker

_Thread_local uint8_t fr_dns_marker[65536]
static

Definition at line 42 of file base.c.

◆ fr_dns_packet_names

char const* fr_dns_packet_names[FR_DNS_CODE_MAX]
Initial value:
= {
[FR_DNS_QUERY] = "Query",
[FR_DNS_INVERSE_QUERY] = "Inverse-Query",
[FR_DNS_STATUS] = "Status",
[FR_DNS_UPDATE] = "Update",
[FR_DNS_STATEFUL_OPERATION] = "Stateful-Operation",
}
@ FR_DNS_STATEFUL_OPERATION
Definition: dns.h:89
@ FR_DNS_QUERY
Definition: dns.h:84
@ FR_DNS_INVERSE_QUERY
Definition: dns.h:85
@ FR_DNS_STATUS
Definition: dns.h:86
@ FR_DNS_UPDATE
Definition: dns.h:88

Definition at line 68 of file base.c.

◆ instance_count

uint32_t instance_count = 0
static

Definition at line 31 of file base.c.

◆ libfreeradius_dns_dict_protocol

fr_dict_protocol_t libfreeradius_dns_dict_protocol
Initial value:
= {
.name = "dns",
.default_type_size = 2,
.default_type_length = 2,
.attr = {
.flags = {
.table = dns_flags,
.table_len = NUM_ELEMENTS(dns_flags),
.len = sizeof(fr_dns_attr_flags_t)
},
.valid = attr_valid
},
}
#define NUM_ELEMENTS(_t)
Definition: build.h:335
int fr_dns_global_init(void)
Resolve/cache attributes in the DNS dictionary.
Definition: base.c:412
static bool attr_valid(fr_dict_attr_t *da)
Definition: base.c:443
void fr_dns_global_free(void)
Definition: base.c:434
static fr_dict_flag_parser_t const dns_flags[]
Definition: base.c:79

Definition at line 465 of file base.c.