Electroneum
pkthdr.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LDNS_HEADER_SIZE   12
 
#define LDNS_RD_MASK   0x01U
 
#define LDNS_RD_SHIFT   0
 
#define LDNS_RD_WIRE(wirebuf)   (*(wirebuf+2) & LDNS_RD_MASK)
 
#define LDNS_RD_SET(wirebuf)   (*(wirebuf+2) |= LDNS_RD_MASK)
 
#define LDNS_RD_CLR(wirebuf)   (*(wirebuf+2) &= ~LDNS_RD_MASK)
 
#define LDNS_TC_MASK   0x02U
 
#define LDNS_TC_SHIFT   1
 
#define LDNS_TC_WIRE(wirebuf)   (*(wirebuf+2) & LDNS_TC_MASK)
 
#define LDNS_TC_SET(wirebuf)   (*(wirebuf+2) |= LDNS_TC_MASK)
 
#define LDNS_TC_CLR(wirebuf)   (*(wirebuf+2) &= ~LDNS_TC_MASK)
 
#define LDNS_AA_MASK   0x04U
 
#define LDNS_AA_SHIFT   2
 
#define LDNS_AA_WIRE(wirebuf)   (*(wirebuf+2) & LDNS_AA_MASK)
 
#define LDNS_AA_SET(wirebuf)   (*(wirebuf+2) |= LDNS_AA_MASK)
 
#define LDNS_AA_CLR(wirebuf)   (*(wirebuf+2) &= ~LDNS_AA_MASK)
 
#define LDNS_OPCODE_MASK   0x78U
 
#define LDNS_OPCODE_SHIFT   3
 
#define LDNS_OPCODE_WIRE(wirebuf)   ((*(wirebuf+2) & LDNS_OPCODE_MASK) >> LDNS_OPCODE_SHIFT)
 
#define LDNS_OPCODE_SET(wirebuf, opcode)   (*(wirebuf+2) = ((*(wirebuf+2)) & ~LDNS_OPCODE_MASK) | ((opcode) << LDNS_OPCODE_SHIFT))
 
#define LDNS_QR_MASK   0x80U
 
#define LDNS_QR_SHIFT   7
 
#define LDNS_QR_WIRE(wirebuf)   (*(wirebuf+2) & LDNS_QR_MASK)
 
#define LDNS_QR_SET(wirebuf)   (*(wirebuf+2) |= LDNS_QR_MASK)
 
#define LDNS_QR_CLR(wirebuf)   (*(wirebuf+2) &= ~LDNS_QR_MASK)
 
#define LDNS_RCODE_MASK   0x0fU
 
#define LDNS_RCODE_SHIFT   0
 
#define LDNS_RCODE_WIRE(wirebuf)   (*(wirebuf+3) & LDNS_RCODE_MASK)
 
#define LDNS_RCODE_SET(wirebuf, rcode)   (*(wirebuf+3) = ((*(wirebuf+3)) & ~LDNS_RCODE_MASK) | (rcode))
 
#define LDNS_CD_MASK   0x10U
 
#define LDNS_CD_SHIFT   4
 
#define LDNS_CD_WIRE(wirebuf)   (*(wirebuf+3) & LDNS_CD_MASK)
 
#define LDNS_CD_SET(wirebuf)   (*(wirebuf+3) |= LDNS_CD_MASK)
 
#define LDNS_CD_CLR(wirebuf)   (*(wirebuf+3) &= ~LDNS_CD_MASK)
 
#define LDNS_AD_MASK   0x20U
 
#define LDNS_AD_SHIFT   5
 
#define LDNS_AD_WIRE(wirebuf)   (*(wirebuf+3) & LDNS_AD_MASK)
 
#define LDNS_AD_SET(wirebuf)   (*(wirebuf+3) |= LDNS_AD_MASK)
 
#define LDNS_AD_CLR(wirebuf)   (*(wirebuf+3) &= ~LDNS_AD_MASK)
 
#define LDNS_Z_MASK   0x40U
 
#define LDNS_Z_SHIFT   6
 
#define LDNS_Z_WIRE(wirebuf)   (*(wirebuf+3) & LDNS_Z_MASK)
 
#define LDNS_Z_SET(wirebuf)   (*(wirebuf+3) |= LDNS_Z_MASK)
 
#define LDNS_Z_CLR(wirebuf)   (*(wirebuf+3) &= ~LDNS_Z_MASK)
 
#define LDNS_RA_MASK   0x80U
 
#define LDNS_RA_SHIFT   7
 
#define LDNS_RA_WIRE(wirebuf)   (*(wirebuf+3) & LDNS_RA_MASK)
 
#define LDNS_RA_SET(wirebuf)   (*(wirebuf+3) |= LDNS_RA_MASK)
 
#define LDNS_RA_CLR(wirebuf)   (*(wirebuf+3) &= ~LDNS_RA_MASK)
 
#define LDNS_ID_WIRE(wirebuf)   (sldns_read_uint16(wirebuf))
 
#define LDNS_ID_SET(wirebuf, id)   (sldns_write_uint16(wirebuf, id))
 
#define LDNS_QDCOUNT_OFF   4
 
#define LDNS_QDCOUNT(wirebuf)   (sldns_read_uint16(wirebuf+LDNS_QDCOUNT_OFF))
 
#define LDNS_ANCOUNT_OFF   6
 
#define LDNS_ANCOUNT(wirebuf)   (sldns_read_uint16(wirebuf+LDNS_ANCOUNT_OFF))
 
#define LDNS_NSCOUNT_OFF   8
 
#define LDNS_NSCOUNT(wirebuf)   (sldns_read_uint16(wirebuf+LDNS_NSCOUNT_OFF))
 
#define LDNS_ARCOUNT_OFF   10
 
#define LDNS_ARCOUNT(wirebuf)   (sldns_read_uint16(wirebuf+LDNS_ARCOUNT_OFF))
 

Typedefs

typedef enum sldns_enum_pkt_section sldns_pkt_section
 
typedef enum sldns_enum_pkt_opcode sldns_pkt_opcode
 
typedef enum sldns_enum_pkt_rcode sldns_pkt_rcode
 

Enumerations

enum  sldns_enum_pkt_section {
  LDNS_SECTION_QUESTION = 0, LDNS_SECTION_ANSWER = 1, LDNS_SECTION_AUTHORITY = 2, LDNS_SECTION_ADDITIONAL = 3,
  LDNS_SECTION_ANY = 4, LDNS_SECTION_ANY_NOQUESTION = 5
}
 
enum  sldns_enum_pkt_opcode {
  LDNS_PACKET_QUERY = 0, LDNS_PACKET_IQUERY = 1, LDNS_PACKET_STATUS = 2, LDNS_PACKET_NOTIFY = 4,
  LDNS_PACKET_UPDATE = 5
}
 
enum  sldns_enum_pkt_rcode {
  LDNS_RCODE_NOERROR = 0, LDNS_RCODE_FORMERR = 1, LDNS_RCODE_SERVFAIL = 2, LDNS_RCODE_NXDOMAIN = 3,
  LDNS_RCODE_NOTIMPL = 4, LDNS_RCODE_REFUSED = 5, LDNS_RCODE_YXDOMAIN = 6, LDNS_RCODE_YXRRSET = 7,
  LDNS_RCODE_NXRRSET = 8, LDNS_RCODE_NOTAUTH = 9, LDNS_RCODE_NOTZONE = 10
}
 

Detailed Description

Contains functions that translate dns data from the wire format (as sent by servers and clients) to the internal structures for the packet header.

Definition in file pkthdr.h.

Macro Definition Documentation

◆ LDNS_AA_CLR

#define LDNS_AA_CLR (   wirebuf)    (*(wirebuf+2) &= ~LDNS_AA_MASK)

Definition at line 45 of file pkthdr.h.

◆ LDNS_AA_MASK

#define LDNS_AA_MASK   0x04U

Definition at line 41 of file pkthdr.h.

◆ LDNS_AA_SET

#define LDNS_AA_SET (   wirebuf)    (*(wirebuf+2) |= LDNS_AA_MASK)

Definition at line 44 of file pkthdr.h.

◆ LDNS_AA_SHIFT

#define LDNS_AA_SHIFT   2

Definition at line 42 of file pkthdr.h.

◆ LDNS_AA_WIRE

#define LDNS_AA_WIRE (   wirebuf)    (*(wirebuf+2) & LDNS_AA_MASK)

Definition at line 43 of file pkthdr.h.

◆ LDNS_AD_CLR

#define LDNS_AD_CLR (   wirebuf)    (*(wirebuf+3) &= ~LDNS_AD_MASK)

Definition at line 76 of file pkthdr.h.

◆ LDNS_AD_MASK

#define LDNS_AD_MASK   0x20U

Definition at line 72 of file pkthdr.h.

◆ LDNS_AD_SET

#define LDNS_AD_SET (   wirebuf)    (*(wirebuf+3) |= LDNS_AD_MASK)

Definition at line 75 of file pkthdr.h.

◆ LDNS_AD_SHIFT

#define LDNS_AD_SHIFT   5

Definition at line 73 of file pkthdr.h.

◆ LDNS_AD_WIRE

#define LDNS_AD_WIRE (   wirebuf)    (*(wirebuf+3) & LDNS_AD_MASK)

Definition at line 74 of file pkthdr.h.

◆ LDNS_ANCOUNT

#define LDNS_ANCOUNT (   wirebuf)    (sldns_read_uint16(wirebuf+LDNS_ANCOUNT_OFF))

Definition at line 103 of file pkthdr.h.

◆ LDNS_ANCOUNT_OFF

#define LDNS_ANCOUNT_OFF   6

Definition at line 102 of file pkthdr.h.

◆ LDNS_ARCOUNT

#define LDNS_ARCOUNT (   wirebuf)    (sldns_read_uint16(wirebuf+LDNS_ARCOUNT_OFF))

Definition at line 111 of file pkthdr.h.

◆ LDNS_ARCOUNT_OFF

#define LDNS_ARCOUNT_OFF   10

Definition at line 110 of file pkthdr.h.

◆ LDNS_CD_CLR

#define LDNS_CD_CLR (   wirebuf)    (*(wirebuf+3) &= ~LDNS_CD_MASK)

Definition at line 70 of file pkthdr.h.

◆ LDNS_CD_MASK

#define LDNS_CD_MASK   0x10U

Definition at line 66 of file pkthdr.h.

◆ LDNS_CD_SET

#define LDNS_CD_SET (   wirebuf)    (*(wirebuf+3) |= LDNS_CD_MASK)

Definition at line 69 of file pkthdr.h.

◆ LDNS_CD_SHIFT

#define LDNS_CD_SHIFT   4

Definition at line 67 of file pkthdr.h.

◆ LDNS_CD_WIRE

#define LDNS_CD_WIRE (   wirebuf)    (*(wirebuf+3) & LDNS_CD_MASK)

Definition at line 68 of file pkthdr.h.

◆ LDNS_HEADER_SIZE

#define LDNS_HEADER_SIZE   12

Definition at line 26 of file pkthdr.h.

◆ LDNS_ID_SET

#define LDNS_ID_SET (   wirebuf,
  id 
)    (sldns_write_uint16(wirebuf, id))

Definition at line 92 of file pkthdr.h.

◆ LDNS_ID_WIRE

#define LDNS_ID_WIRE (   wirebuf)    (sldns_read_uint16(wirebuf))

Definition at line 91 of file pkthdr.h.

◆ LDNS_NSCOUNT

#define LDNS_NSCOUNT (   wirebuf)    (sldns_read_uint16(wirebuf+LDNS_NSCOUNT_OFF))

Definition at line 107 of file pkthdr.h.

◆ LDNS_NSCOUNT_OFF

#define LDNS_NSCOUNT_OFF   8

Definition at line 106 of file pkthdr.h.

◆ LDNS_OPCODE_MASK

#define LDNS_OPCODE_MASK   0x78U

Definition at line 47 of file pkthdr.h.

◆ LDNS_OPCODE_SET

#define LDNS_OPCODE_SET (   wirebuf,
  opcode 
)    (*(wirebuf+2) = ((*(wirebuf+2)) & ~LDNS_OPCODE_MASK) | ((opcode) << LDNS_OPCODE_SHIFT))

Definition at line 50 of file pkthdr.h.

◆ LDNS_OPCODE_SHIFT

#define LDNS_OPCODE_SHIFT   3

Definition at line 48 of file pkthdr.h.

◆ LDNS_OPCODE_WIRE

#define LDNS_OPCODE_WIRE (   wirebuf)    ((*(wirebuf+2) & LDNS_OPCODE_MASK) >> LDNS_OPCODE_SHIFT)

Definition at line 49 of file pkthdr.h.

◆ LDNS_QDCOUNT

#define LDNS_QDCOUNT (   wirebuf)    (sldns_read_uint16(wirebuf+LDNS_QDCOUNT_OFF))

Definition at line 99 of file pkthdr.h.

◆ LDNS_QDCOUNT_OFF

#define LDNS_QDCOUNT_OFF   4

Definition at line 95 of file pkthdr.h.

◆ LDNS_QR_CLR

#define LDNS_QR_CLR (   wirebuf)    (*(wirebuf+2) &= ~LDNS_QR_MASK)

Definition at line 57 of file pkthdr.h.

◆ LDNS_QR_MASK

#define LDNS_QR_MASK   0x80U

Definition at line 53 of file pkthdr.h.

◆ LDNS_QR_SET

#define LDNS_QR_SET (   wirebuf)    (*(wirebuf+2) |= LDNS_QR_MASK)

Definition at line 56 of file pkthdr.h.

◆ LDNS_QR_SHIFT

#define LDNS_QR_SHIFT   7

Definition at line 54 of file pkthdr.h.

◆ LDNS_QR_WIRE

#define LDNS_QR_WIRE (   wirebuf)    (*(wirebuf+2) & LDNS_QR_MASK)

Definition at line 55 of file pkthdr.h.

◆ LDNS_RA_CLR

#define LDNS_RA_CLR (   wirebuf)    (*(wirebuf+3) &= ~LDNS_RA_MASK)

Definition at line 88 of file pkthdr.h.

◆ LDNS_RA_MASK

#define LDNS_RA_MASK   0x80U

Definition at line 84 of file pkthdr.h.

◆ LDNS_RA_SET

#define LDNS_RA_SET (   wirebuf)    (*(wirebuf+3) |= LDNS_RA_MASK)

Definition at line 87 of file pkthdr.h.

◆ LDNS_RA_SHIFT

#define LDNS_RA_SHIFT   7

Definition at line 85 of file pkthdr.h.

◆ LDNS_RA_WIRE

#define LDNS_RA_WIRE (   wirebuf)    (*(wirebuf+3) & LDNS_RA_MASK)

Definition at line 86 of file pkthdr.h.

◆ LDNS_RCODE_MASK

#define LDNS_RCODE_MASK   0x0fU

Definition at line 60 of file pkthdr.h.

◆ LDNS_RCODE_SET

#define LDNS_RCODE_SET (   wirebuf,
  rcode 
)    (*(wirebuf+3) = ((*(wirebuf+3)) & ~LDNS_RCODE_MASK) | (rcode))

Definition at line 63 of file pkthdr.h.

◆ LDNS_RCODE_SHIFT

#define LDNS_RCODE_SHIFT   0

Definition at line 61 of file pkthdr.h.

◆ LDNS_RCODE_WIRE

#define LDNS_RCODE_WIRE (   wirebuf)    (*(wirebuf+3) & LDNS_RCODE_MASK)

Definition at line 62 of file pkthdr.h.

◆ LDNS_RD_CLR

#define LDNS_RD_CLR (   wirebuf)    (*(wirebuf+2) &= ~LDNS_RD_MASK)

Definition at line 33 of file pkthdr.h.

◆ LDNS_RD_MASK

#define LDNS_RD_MASK   0x01U

Definition at line 29 of file pkthdr.h.

◆ LDNS_RD_SET

#define LDNS_RD_SET (   wirebuf)    (*(wirebuf+2) |= LDNS_RD_MASK)

Definition at line 32 of file pkthdr.h.

◆ LDNS_RD_SHIFT

#define LDNS_RD_SHIFT   0

Definition at line 30 of file pkthdr.h.

◆ LDNS_RD_WIRE

#define LDNS_RD_WIRE (   wirebuf)    (*(wirebuf+2) & LDNS_RD_MASK)

Definition at line 31 of file pkthdr.h.

◆ LDNS_TC_CLR

#define LDNS_TC_CLR (   wirebuf)    (*(wirebuf+2) &= ~LDNS_TC_MASK)

Definition at line 39 of file pkthdr.h.

◆ LDNS_TC_MASK

#define LDNS_TC_MASK   0x02U

Definition at line 35 of file pkthdr.h.

◆ LDNS_TC_SET

#define LDNS_TC_SET (   wirebuf)    (*(wirebuf+2) |= LDNS_TC_MASK)

Definition at line 38 of file pkthdr.h.

◆ LDNS_TC_SHIFT

#define LDNS_TC_SHIFT   1

Definition at line 36 of file pkthdr.h.

◆ LDNS_TC_WIRE

#define LDNS_TC_WIRE (   wirebuf)    (*(wirebuf+2) & LDNS_TC_MASK)

Definition at line 37 of file pkthdr.h.

◆ LDNS_Z_CLR

#define LDNS_Z_CLR (   wirebuf)    (*(wirebuf+3) &= ~LDNS_Z_MASK)

Definition at line 82 of file pkthdr.h.

◆ LDNS_Z_MASK

#define LDNS_Z_MASK   0x40U

Definition at line 78 of file pkthdr.h.

◆ LDNS_Z_SET

#define LDNS_Z_SET (   wirebuf)    (*(wirebuf+3) |= LDNS_Z_MASK)

Definition at line 81 of file pkthdr.h.

◆ LDNS_Z_SHIFT

#define LDNS_Z_SHIFT   6

Definition at line 79 of file pkthdr.h.

◆ LDNS_Z_WIRE

#define LDNS_Z_WIRE (   wirebuf)    (*(wirebuf+3) & LDNS_Z_MASK)

Definition at line 80 of file pkthdr.h.

Typedef Documentation

◆ sldns_pkt_opcode

Definition at line 136 of file pkthdr.h.

◆ sldns_pkt_rcode

Definition at line 152 of file pkthdr.h.

◆ sldns_pkt_section

Definition at line 126 of file pkthdr.h.

Enumeration Type Documentation

◆ sldns_enum_pkt_opcode

Enumerator
LDNS_PACKET_QUERY 
LDNS_PACKET_IQUERY 
LDNS_PACKET_STATUS 
LDNS_PACKET_NOTIFY 
LDNS_PACKET_UPDATE 

Definition at line 129 of file pkthdr.h.

129  {
130  LDNS_PACKET_QUERY = 0,
131  LDNS_PACKET_IQUERY = 1,
132  LDNS_PACKET_STATUS = 2, /* there is no 3?? DNS is weird */
133  LDNS_PACKET_NOTIFY = 4,
135 };

◆ sldns_enum_pkt_rcode

Enumerator
LDNS_RCODE_NOERROR 
LDNS_RCODE_FORMERR 
LDNS_RCODE_SERVFAIL 
LDNS_RCODE_NXDOMAIN 
LDNS_RCODE_NOTIMPL 
LDNS_RCODE_REFUSED 
LDNS_RCODE_YXDOMAIN 
LDNS_RCODE_YXRRSET 
LDNS_RCODE_NXRRSET 
LDNS_RCODE_NOTAUTH 
LDNS_RCODE_NOTZONE 

Definition at line 139 of file pkthdr.h.

◆ sldns_enum_pkt_section

The sections of a packet

Enumerator
LDNS_SECTION_QUESTION 
LDNS_SECTION_ANSWER 
LDNS_SECTION_AUTHORITY 
LDNS_SECTION_ADDITIONAL 
LDNS_SECTION_ANY 

bogus section, if not interested

LDNS_SECTION_ANY_NOQUESTION 

used to get all non-question rrs from a packet

Definition at line 116 of file pkthdr.h.