The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Enumerations | Functions | Variables
dns.h File Reference

Implementation of the DNS protocol. More...

#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/util/dns.h>
+ Include dependency graph for dns.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_dns_attr_flags_t
 
struct  fr_dns_ctx_t
 
struct  fr_dns_packet_t
 

Macros

#define DNS_HDR_LEN   (12)
 
#define DNS_MAX_ATTRIBUTES   255
 
#define fr_dns_flag_dns_label(_da)   (fr_dns_attr_flags(_da)->dns_label)
 
#define fr_dns_flag_dns_label_uncompressed(_da)   (fr_dns_attr_flags(_da)->dns_label_uncompressed)
 
#define FR_DNS_PACKET_CODE_VALID(_code)   (((_code) < FR_DNS_CODE_MAX) || (((_code & 0x10) != 0) && ((_code & ~0x10) < FR_DNS_CODE_MAX)))
 

Enumerations

enum  fr_dns_decode_fail_t {
  FR_DNS_DECODE_FAIL_NONE = 0 ,
  FR_DNS_DECODE_FAIL_MIN_LENGTH_PACKET ,
  FR_DNS_DECODE_FAIL_MAX_LENGTH_PACKET ,
  FR_DNS_DECODE_FAIL_UNEXPECTED ,
  FR_DNS_DECODE_FAIL_NO_QUESTIONS ,
  FR_DNS_DECODE_FAIL_ANSWERS_IN_QUESTION ,
  FR_DNS_DECODE_FAIL_NS_IN_QUESTION ,
  FR_DNS_DECODE_FAIL_INVALID_RR_LABEL ,
  FR_DNS_DECODE_FAIL_MISSING_RR_HEADER ,
  FR_DNS_DECODE_FAIL_MISSING_RR_LEN ,
  FR_DNS_DECODE_FAIL_ZERO_RR_LEN ,
  FR_DNS_DECODE_FAIL_RR_OVERFLOWS_PACKET ,
  FR_DNS_DECODE_FAIL_TOO_MANY_RRS ,
  FR_DNS_DECODE_FAIL_TOO_FEW_RRS ,
  FR_DNS_DECODE_FAIL_POINTER_TO_NON_LABEL ,
  FR_DNS_DECODE_FAIL_POINTER_OVERFLOWS_PACKET ,
  FR_DNS_DECODE_FAIL_POINTER_TO_HEADER ,
  FR_DNS_DECODE_FAIL_POINTER_LOOPS ,
  FR_DNS_DECODE_FAIL_INVALID_POINTER ,
  FR_DNS_DECODE_FAIL_LABEL_OVERFLOWS_PACKET ,
  FR_DNS_DECODE_FAIL_LABEL_TOO_LONG ,
  FR_DNS_DECODE_FAIL_MISSING_QD_HEADER ,
  FR_DNS_DECODE_FAIL_MISSING_TLV_HEADER ,
  FR_DNS_DECODE_FAIL_TLV_OVERFLOWS_RR ,
  FR_DNS_DECODE_FAIL_MAX
}
 
enum  fr_dns_packet_code_t {
  FR_DNS_QUERY = 0 ,
  FR_DNS_INVERSE_QUERY = 1 ,
  FR_DNS_STATUS = 2 ,
  FR_DNS_NOTIFY = 4 ,
  FR_DNS_UPDATE = 5 ,
  FR_DNS_STATEFUL_OPERATION = 6 ,
  FR_DNS_CODE_MAX = 7 ,
  FR_DNS_QUERY_RESPONSE = 16 ,
  FR_DNS_INVERSE_QUERY_RESPONSE = 17 ,
  FR_DNS_STATUS_RESPONSE = 18 ,
  FR_DNS_NOTIFY_RESPONSE = 20 ,
  FR_DNS_UPDATE_RESPONSE = 21 ,
  FR_DNS_STATEFUL_OPERATION_RESPONSE = 22 ,
  FR_DNS_DO_NOT_RESPOND = 256
}
 

Functions

static fr_dns_attr_flags_t const * fr_dns_attr_flags (fr_dict_attr_t const *da)
 
ssize_t fr_dns_decode (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *packet, size_t packet_len, fr_dns_ctx_t *packet_ctx)
 Decode a DNS packet. More...
 
ssize_t fr_dns_encode (fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_dns_ctx_t *encode_ctx)
 Encode a DNS packet. More...
 
static bool fr_dns_flag_dns_label_any (fr_dict_attr_t const *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)
 

Variables

char const * fr_dns_packet_names [FR_DNS_CODE_MAX]
 
fr_table_num_ordered_t fr_dns_reason_fail_table []
 
size_t fr_dns_reason_fail_table_len
 

Detailed Description

Implementation of the DNS protocol.

Id
ccd4976e6e62129e2296fc9db32c33ed27714112

Definition in file dns.h.


Data Structure Documentation

◆ fr_dns_attr_flags_t

struct fr_dns_attr_flags_t

Definition at line 134 of file dns.h.

Data Fields
bool dns_label
bool dns_label_uncompressed

◆ fr_dns_ctx_t

struct fr_dns_ctx_t

Definition at line 73 of file dns.h.

+ Collaboration diagram for fr_dns_ctx_t:
Data Fields
fr_dns_labels_t * lb
uint8_t const * packet DNS labels can point anywhere in the packet :(.
size_t packet_len
TALLOC_CTX * tmp_ctx for temporary things cleaned up during decoding

◆ fr_dns_packet_t

struct fr_dns_packet_t

Definition at line 37 of file dns.h.

Data Fields
uint16_t ancount
uint16_t arcount
unsigned int authentic_data: 1
unsigned int authoritative: 1
unsigned int checking_disabled: 1
uint16_t id
uint16_t nscount
unsigned int opcode: 4
uint16_t qdcount
unsigned int query: 1
unsigned int rcode: 4
unsigned int recursion_available: 1
unsigned int recursion_desired: 1
unsigned int reserved: 1
unsigned int truncated: 1

Macro Definition Documentation

◆ DNS_HDR_LEN

#define DNS_HDR_LEN   (12)

Definition at line 132 of file dns.h.

◆ DNS_MAX_ATTRIBUTES

#define DNS_MAX_ATTRIBUTES   255

Definition at line 35 of file dns.h.

◆ fr_dns_flag_dns_label

#define fr_dns_flag_dns_label (   _da)    (fr_dns_attr_flags(_da)->dns_label)

Definition at line 151 of file dns.h.

◆ fr_dns_flag_dns_label_uncompressed

#define fr_dns_flag_dns_label_uncompressed (   _da)    (fr_dns_attr_flags(_da)->dns_label_uncompressed)

Definition at line 152 of file dns.h.

◆ FR_DNS_PACKET_CODE_VALID

#define FR_DNS_PACKET_CODE_VALID (   _code)    (((_code) < FR_DNS_CODE_MAX) || (((_code & 0x10) != 0) && ((_code & ~0x10) < FR_DNS_CODE_MAX)))

Definition at line 130 of file dns.h.

Enumeration Type Documentation

◆ fr_dns_decode_fail_t

Enumerator
FR_DNS_DECODE_FAIL_NONE 
FR_DNS_DECODE_FAIL_MIN_LENGTH_PACKET 
FR_DNS_DECODE_FAIL_MAX_LENGTH_PACKET 
FR_DNS_DECODE_FAIL_UNEXPECTED 
FR_DNS_DECODE_FAIL_NO_QUESTIONS 
FR_DNS_DECODE_FAIL_ANSWERS_IN_QUESTION 
FR_DNS_DECODE_FAIL_NS_IN_QUESTION 
FR_DNS_DECODE_FAIL_INVALID_RR_LABEL 
FR_DNS_DECODE_FAIL_MISSING_RR_HEADER 
FR_DNS_DECODE_FAIL_MISSING_RR_LEN 
FR_DNS_DECODE_FAIL_ZERO_RR_LEN 
FR_DNS_DECODE_FAIL_RR_OVERFLOWS_PACKET 
FR_DNS_DECODE_FAIL_TOO_MANY_RRS 
FR_DNS_DECODE_FAIL_TOO_FEW_RRS 
FR_DNS_DECODE_FAIL_POINTER_TO_NON_LABEL 
FR_DNS_DECODE_FAIL_POINTER_OVERFLOWS_PACKET 
FR_DNS_DECODE_FAIL_POINTER_TO_HEADER 
FR_DNS_DECODE_FAIL_POINTER_LOOPS 
FR_DNS_DECODE_FAIL_INVALID_POINTER 
FR_DNS_DECODE_FAIL_LABEL_OVERFLOWS_PACKET 
FR_DNS_DECODE_FAIL_LABEL_TOO_LONG 
FR_DNS_DECODE_FAIL_MISSING_QD_HEADER 
FR_DNS_DECODE_FAIL_MISSING_TLV_HEADER 
FR_DNS_DECODE_FAIL_TLV_OVERFLOWS_RR 
FR_DNS_DECODE_FAIL_MAX 

Definition at line 102 of file dns.h.

◆ fr_dns_packet_code_t

Enumerator
FR_DNS_QUERY 
FR_DNS_INVERSE_QUERY 
FR_DNS_STATUS 
FR_DNS_NOTIFY 
FR_DNS_UPDATE 
FR_DNS_STATEFUL_OPERATION 
FR_DNS_CODE_MAX 
FR_DNS_QUERY_RESPONSE 
FR_DNS_INVERSE_QUERY_RESPONSE 
FR_DNS_STATUS_RESPONSE 
FR_DNS_NOTIFY_RESPONSE 
FR_DNS_UPDATE_RESPONSE 
FR_DNS_STATEFUL_OPERATION_RESPONSE 
FR_DNS_DO_NOT_RESPOND 

Definition at line 83 of file dns.h.

Function Documentation

◆ fr_dns_attr_flags()

static fr_dns_attr_flags_t const* fr_dns_attr_flags ( fr_dict_attr_t const *  da)
inlinestatic

Definition at line 139 of file dns.h.

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

◆ fr_dns_decode()

ssize_t fr_dns_decode ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
uint8_t const *  packet,
size_t  packet_len,
fr_dns_ctx_t packet_ctx 
)

Decode a DNS packet.

Definition at line 265 of file decode.c.

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

◆ fr_dns_encode()

ssize_t fr_dns_encode ( fr_dbuff_t dbuff,
fr_pair_list_t vps,
fr_dns_ctx_t encode_ctx 
)

Encode a DNS packet.

Definition at line 451 of file encode.c.

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

◆ fr_dns_flag_dns_label_any()

static bool fr_dns_flag_dns_label_any ( fr_dict_attr_t const *  da)
inlinestatic

Definition at line 144 of file dns.h.

+ Here is the call graph for this function:
+ Here is the caller 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:

Variable Documentation

◆ fr_dns_packet_names

char const* fr_dns_packet_names[FR_DNS_CODE_MAX]
extern

Definition at line 68 of file base.c.

◆ fr_dns_reason_fail_table

fr_table_num_ordered_t fr_dns_reason_fail_table[]
extern

Definition at line 387 of file decode.c.

◆ fr_dns_reason_fail_table_len

size_t fr_dns_reason_fail_table_len
extern

Definition at line 413 of file decode.c.