FD.io VPP
v18.01-8-g0eacf49
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
dns_packet.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
#ifndef included_dns_packet_h
17
#define included_dns_packet_h
18
19
/**
20
* DNS packet header format
21
*/
22
23
/* *INDENT-OFF* */
24
typedef
CLIB_PACKED
(
struct
{
25
u16
id;
/**< transaction ID */
26
u16
flags
;
/**< flags */
27
u16
qdcount;
/**< number of questions */
28
u16
anscount;
/**< number of answers */
29
u16
nscount;
/**< number of name servers */
30
u16
arcount;
/**< number of additional records */
31
}) dns_header_t;
32
/* *INDENT-ON* */
33
34
#define DNS_RCODE_MASK (0xf)
35
#define DNS_RCODE_NO_ERROR 0
36
#define DNS_RCODE_FORMAT_ERROR 1
37
#define DNS_RCODE_SERVER_FAILURE 2
38
#define DNS_RCODE_NAME_ERROR 3
39
#define DNS_RCODE_NOT_IMPLEMENTED 4
40
#define DNS_RCODE_REFUSED 5
41
42
#define DNS_RA (1<<7)
/**< recursion available */
43
#define DNS_RD (1<<8)
/**< recursion desired */
44
#define DNS_TC (1<<9)
/**< truncation */
45
#define DNS_AA (1<<10)
/**< authoritative answer */
46
#define DNS_OPCODE_MASK (0xf<<11)
/**< opcode mask */
47
#define DNS_OPCODE_QUERY (0<<11)
/**< standard query */
48
#define DNS_OPCODE_IQUERY (1<<11)
/**< inverse query (deprecated) */
49
#define DNS_OPCODE_STATUS (2<<11)
/**< server status */
50
#define DNS_QR (1<<15)
/**< query=0, response=1 */
51
52
53
/*
54
* Note: in DNS-land, www.foobar.com is encoded as three "labels,"
55
* each of which amount to a 1 octet length followed by up to 63
56
* octets of name. Don't forget to add a "null root label" after the last
57
* real one, or the poor slob trying to parse the name will have
58
* no chance whatsoever.
59
*
60
* All RRs have the same top level format shown below:
61
*
62
* 1 1 1 1 1 1
63
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
64
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
65
* | |
66
* / /
67
* / NAME /
68
* | |
69
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
70
* | TYPE |
71
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
72
* | CLASS |
73
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
74
* | TTL |
75
* | |
76
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
77
* | RDLENGTH |
78
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
79
* / RDATA /
80
* / /
81
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
82
*
83
*
84
* DNS "questions" have the following format:
85
*
86
* 1 1 1 1 1 1
87
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
88
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
89
* | |
90
* / QNAME /
91
* / /
92
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
93
* | QTYPE |
94
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
95
* | QCLASS |
96
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
97
*/
98
99
/**
100
* DNS "question" fixed header.
101
*/
102
/* *INDENT-OFF* */
103
typedef
CLIB_PACKED
(
struct
{
104
u16
type;
/**< record type requested */
105
u16
class
;
/**< class, 1 = internet */
106
}) dns_query_t;
107
/* *INDENT-ON* */
108
109
/**
110
* DNS RR fixed header.
111
*/
112
/* *INDENT-OFF* */
113
typedef
CLIB_PACKED
(
struct
{
114
u16
type;
/**< record type */
115
u16
class
;
/**< class, 1 = internet */
116
u32
ttl;
/**< time to live, in seconds */
117
u16
rdlength;
118
/**< length of r */
119
u8
rdata[0];
120
}) dns_rr_t;
121
/* *INDENT-ON* */
122
123
/*
124
* There are quite a number of DNS record types
125
* Feel free to add as needed
126
*/
127
#define foreach_dns_type \
128
_(A, 1)
/**< ip4 host address */
\
129
_(AAAA, 28)
/**< ip6 host address */
\
130
_(ALL, 255)
/**< all available data */
\
131
_(TEXT, 16)
/**< a text string */
\
132
_(NAMESERVER, 2)
/**< a nameserver */
\
133
_(CNAME, 5)
/**< a CNAME (alias) */
\
134
_(MAIL_EXCHANGE, 15)
/**< a mail exchange */
\
135
_(PTR, 12)
/**< a PTR (pointer) record */
\
136
_(HINFO, 13)
/**< Host info */
137
138
typedef
enum
139
{
140
#define _(name,value) DNS_TYPE_##name = value,
141
foreach_dns_type
142
#undef _
143
}
dns_type_t
;
144
145
#define DNS_CLASS_IN 1
/**< The Internet */
146
147
148
#endif
/* included_dns_packet_h */
149
150
/*
151
* fd.io coding-style-patch-verification: ON
152
*
153
* Local Variables:
154
* eval: (c-set-style "gnu")
155
* End:
156
*/
dns_type_t
dns_type_t
Definition:
dns_packet.h:138
foreach_dns_type
#define foreach_dns_type
Host info.
Definition:
dns_packet.h:127
u32
unsigned int u32
Definition:
types.h:88
u16
unsigned short u16
Definition:
types.h:57
u8
unsigned char u8
Definition:
types.h:56
CLIB_PACKED
typedef CLIB_PACKED(struct{u16 id;u16 flags;u16 qdcount;u16 anscount;u16 nscount;u16 arcount;}) dns_header_t
DNS packet header format.
flags
u32 flags
Definition:
vhost-user.h:77
src
vnet
dns
dns_packet.h
Generated on Wed Feb 7 2018 04:46:01 for FD.io VPP by
1.8.11