sdns
low-level DNS library
Loading...
Searching...
No Matches
Public Attributes | List of all members
_sdns_rr Struct Reference

#include <sdns.h>

Collaboration diagram for _sdns_rr:
Collaboration graph
[legend]

Public Attributes

char * name
 RFC1035 - domain name.
 
uint16_t type
 RFC1035 - RR type code.
 
union { 
 
   uint16_t   class 
 RFC1035 - class of the data in rdata.
 
   uint16_t   udp_size 
 size of the UDP packet
 
};  
 
union { 
 
   uint32_t   ttl 
 Time To Live.
 
   sdns_opt_ttl   opt_ttl 
 will expand to sdns_opt_ttl if type=OPT
 
};  
 
uint16_t rdlength
 RFC1035 - length of the RDATA field.
 
union { 
 
   char *   rdata 
 resource record data (for all RRs except for OPT)
 
   sdns_opt_rdata *   opt_rdata 
 if type=OPT, this will refer to sdns_opt_rdata structure
 
   void *   psdns_rr 
 this is not DNS-RFC. It's just a reference for our library
 
};  
 
uint8_t decoded
 this is not DNS-RFC. it's just a flag to know if the rdata is decoded or not
 
struct _sdns_rrnext
 non-rfc field, just keep the reference to the next structure (linked-list)
 

Detailed Description

Each resource record of a DNS packet has the following format. This is the standard format of answer section, authority section and additional section of a DNS packet (RFC1035::Section4.3.1).

  0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                                               |
  /                                               /
  /                      NAME                     /
  |                                               |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                      TYPE                     |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                     CLASS                     |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                      TTL                      |
  |                                               |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  |                   RDLENGTH                    |
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
  /                     RDATA                     /
  /                                               /
  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

  1. NAME is always has the same meaning for all the sections and RRs.
  2. TYPE is always the same and shows the type of the RR.
  3. CLASS is one the values of sdns_rr_class or sdns_q_class. However, when TYPE is sdns_rr_type_OPT (41), then CLASS is the size of the UDP packet. This behaviour defined in RFC2671
  4. TTL is either a 32 bit value showing the time to live of the record (RFC1035) or a 32bit structure of sdns_opt_ttl.
  5. rdlength always contains the length of the data part of the RR.

NOTE: Three fields of this structure are not RFC standard and are only used here as helpers.

  1. decoded: This binary field is either 0 or 1 and it tells the user if the rdata part is decoded or not. When the rdata part is decoded (decoded=1), then we can use psdns_rr pointer and cast it to the correct structure and use it. when the rdata is not decoded (decoded=0), we should treat it as a pointer to char*.
  2. next: a pointer to the same structure for creating a link-list of RRs.

The documentation for this struct was generated from the following file: