Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
msgparse.h
Go to the documentation of this file.
1
/*
2
* util/data/msgparse.h - parse wireformat DNS messages.
3
*
4
* Copyright (c) 2007, NLnet Labs. All rights reserved.
5
*
6
* This software is open source.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
*
12
* Redistributions of source code must retain the above copyright notice,
13
* this list of conditions and the following disclaimer.
14
*
15
* Redistributions in binary form must reproduce the above copyright notice,
16
* this list of conditions and the following disclaimer in the documentation
17
* and/or other materials provided with the distribution.
18
*
19
* Neither the name of the NLNET LABS nor the names of its contributors may
20
* be used to endorse or promote products derived from this software without
21
* specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
62
63
#ifndef UTIL_DATA_MSGPARSE_H
64
#define UTIL_DATA_MSGPARSE_H
65
#include "
util/storage/lruhash.h
"
66
#include "
sldns/pkthdr.h
"
67
#include "
sldns/rrdef.h
"
68
struct
sldns_buffer
;
69
struct
rrset_parse
;
70
struct
rr_parse
;
71
struct
regional
;
72
struct
edns_option
;
73
75
#define PARSE_TABLE_SIZE 32
77
extern
time_t
MAX_TTL
;
79
extern
time_t
MIN_TTL
;
81
extern
time_t
MAX_NEG_TTL
;
83
#define NORR_TTL 5
/* seconds */
84
89
struct
msg_parse
{
91
uint16_t
id
;
93
uint16_t
flags
;
95
uint16_t
qdcount
;
97
uint16_t
ancount
;
99
uint16_t
nscount
;
101
uint16_t
arcount
;
103
size_t
an_rrsets
;
105
size_t
ns_rrsets
;
107
size_t
ar_rrsets
;
109
size_t
rrset_count
;
110
112
uint8_t
*
qname
;
114
size_t
qname_len
;
116
uint16_t
qtype
;
118
uint16_t
qclass
;
119
124
struct
rrset_parse
*
hashtable
[
PARSE_TABLE_SIZE
];
125
127
struct
rrset_parse
*
rrset_first
;
129
struct
rrset_parse
*
rrset_last
;
130
};
131
135
struct
rrset_parse
{
137
struct
rrset_parse
*
rrset_bucket_next
;
139
struct
rrset_parse
*
rrset_all_next
;
141
hashvalue_type
hash
;
145
sldns_pkt_section
section
;
147
uint8_t
*
dname
;
149
size_t
dname_len
;
151
uint16_t
type
;
153
uint16_t
rrset_class
;
155
uint32_t
flags
;
157
size_t
rr_count
;
159
size_t
size
;
161
struct
rr_parse
*
rr_first
;
163
struct
rr_parse
*
rr_last
;
165
size_t
rrsig_count
;
167
struct
rr_parse
*
rrsig_first
;
169
struct
rr_parse
*
rrsig_last
;
170
};
171
175
struct
rr_parse
{
181
uint8_t
*
ttl_data
;
184
int
outside_packet
;
186
size_t
size
;
188
struct
rr_parse
*
next
;
189
};
190
192
#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
195
#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
197
#define PTR_CREATE(offset) ((uint16_t)(0xc000 | (offset)))
198
200
#define EDNS_RCODE_BADVERS 16
202
#define PTR_MAX_OFFSET 0x3fff
203
209
struct
edns_data
{
211
int
edns_present
;
213
uint8_t
ext_rcode
;
215
uint8_t
edns_version
;
217
uint16_t
bits
;
219
uint16_t
udp_size
;
221
struct
edns_option
*
opt_list
;
222
};
223
227
struct
edns_option
{
229
struct
edns_option
*
next
;
231
uint16_t
opt_code
;
233
size_t
opt_len
;
235
uint8_t
*
opt_data
;
236
};
237
244
size_t
get_rdf_size
(
sldns_rdf_type
rdf);
245
254
int
parse_packet
(
struct
sldns_buffer
* pkt,
struct
msg_parse
* msg,
255
struct
regional
* region);
256
274
int
parse_extract_edns
(
struct
msg_parse
* msg,
struct
edns_data
* edns,
275
struct
regional
* region);
276
287
int
parse_edns_from_pkt
(
struct
sldns_buffer
* pkt,
struct
edns_data
* edns,
288
struct
regional
* region);
289
299
hashvalue_type
pkt_hash_rrset
(
struct
sldns_buffer
* pkt,
uint8_t
* dname,
300
uint16_t
type,
uint16_t
dclass,
uint32_t
rrset_flags);
301
314
struct
rrset_parse
*
msgparse_hashtable_lookup
(
struct
msg_parse
* msg,
315
struct
sldns_buffer
* pkt,
hashvalue_type
h,
uint32_t
rrset_flags,
316
uint8_t
*
dname
,
size_t
dnamelen,
uint16_t
type
,
uint16_t
dclass);
317
323
void
msgparse_bucket_remove
(
struct
msg_parse
* msg,
struct
rrset_parse
* rrset);
324
331
void
log_edns_opt_list
(
enum
verbosity_value
level,
const
char
* info_str,
332
struct
edns_option
* list);
333
334
#endif
/* UTIL_DATA_MSGPARSE_H */
verbosity_value
verbosity_value
Definition
log.h:49
lruhash.h
hashvalue_type
uint32_t hashvalue_type
Definition
lruhash.h:119
pkt_hash_rrset
hashvalue_type pkt_hash_rrset(struct sldns_buffer *pkt, uint8_t *dname, uint16_t type, uint16_t dclass, uint32_t rrset_flags)
msgparse_hashtable_lookup
struct rrset_parse * msgparse_hashtable_lookup(struct msg_parse *msg, struct sldns_buffer *pkt, hashvalue_type h, uint32_t rrset_flags, uint8_t *dname, size_t dnamelen, uint16_t type, uint16_t dclass)
parse_extract_edns
int parse_extract_edns(struct msg_parse *msg, struct edns_data *edns, struct regional *region)
MAX_NEG_TTL
time_t MAX_NEG_TTL
PARSE_TABLE_SIZE
#define PARSE_TABLE_SIZE
Definition
msgparse.h:75
parse_packet
int parse_packet(struct sldns_buffer *pkt, struct msg_parse *msg, struct regional *region)
get_rdf_size
size_t get_rdf_size(sldns_rdf_type rdf)
MAX_TTL
time_t MAX_TTL
MIN_TTL
time_t MIN_TTL
msgparse_bucket_remove
void msgparse_bucket_remove(struct msg_parse *msg, struct rrset_parse *rrset)
parse_edns_from_pkt
int parse_edns_from_pkt(struct sldns_buffer *pkt, struct edns_data *edns, struct regional *region)
log_edns_opt_list
void log_edns_opt_list(enum verbosity_value level, const char *info_str, struct edns_option *list)
pkthdr.h
sldns_pkt_section
enum sldns_enum_pkt_section sldns_pkt_section
Definition
pkthdr.h:126
rrdef.h
sldns_rdf_type
enum sldns_enum_rdf_type sldns_rdf_type
Definition
rrdef.h:360
uint16_t
unsigned short uint16_t
Definition
stdint.h:125
uint32_t
unsigned int uint32_t
Definition
stdint.h:126
uint8_t
unsigned char uint8_t
Definition
stdint.h:124
edns_data
Definition
msgparse.h:209
edns_data::ext_rcode
uint8_t ext_rcode
Definition
msgparse.h:213
edns_data::opt_list
struct edns_option * opt_list
Definition
msgparse.h:221
edns_data::bits
uint16_t bits
Definition
msgparse.h:217
edns_data::edns_version
uint8_t edns_version
Definition
msgparse.h:215
edns_data::udp_size
uint16_t udp_size
Definition
msgparse.h:219
edns_data::edns_present
int edns_present
Definition
msgparse.h:211
edns_option
Definition
msgparse.h:227
edns_option::opt_data
uint8_t * opt_data
Definition
msgparse.h:235
edns_option::opt_code
uint16_t opt_code
Definition
msgparse.h:231
edns_option::opt_len
size_t opt_len
Definition
msgparse.h:233
edns_option::next
struct edns_option * next
Definition
msgparse.h:229
msg_parse
Definition
msgparse.h:89
msg_parse::qname
uint8_t * qname
Definition
msgparse.h:112
msg_parse::nscount
uint16_t nscount
Definition
msgparse.h:99
msg_parse::ancount
uint16_t ancount
Definition
msgparse.h:97
msg_parse::qtype
uint16_t qtype
Definition
msgparse.h:116
msg_parse::an_rrsets
size_t an_rrsets
Definition
msgparse.h:103
msg_parse::flags
uint16_t flags
Definition
msgparse.h:93
msg_parse::id
uint16_t id
Definition
msgparse.h:91
msg_parse::arcount
uint16_t arcount
Definition
msgparse.h:101
msg_parse::qclass
uint16_t qclass
Definition
msgparse.h:118
msg_parse::rrset_count
size_t rrset_count
Definition
msgparse.h:109
msg_parse::ar_rrsets
size_t ar_rrsets
Definition
msgparse.h:107
msg_parse::ns_rrsets
size_t ns_rrsets
Definition
msgparse.h:105
msg_parse::rrset_first
struct rrset_parse * rrset_first
Definition
msgparse.h:127
msg_parse::qname_len
size_t qname_len
Definition
msgparse.h:114
msg_parse::hashtable
struct rrset_parse * hashtable[PARSE_TABLE_SIZE]
Definition
msgparse.h:124
msg_parse::rrset_last
struct rrset_parse * rrset_last
Definition
msgparse.h:129
msg_parse::qdcount
uint16_t qdcount
Definition
msgparse.h:95
regional
Definition
regional.h:60
rr_parse
Definition
msgparse.h:175
rr_parse::next
struct rr_parse * next
Definition
msgparse.h:188
rr_parse::size
size_t size
Definition
msgparse.h:186
rr_parse::outside_packet
int outside_packet
Definition
msgparse.h:184
rr_parse::ttl_data
uint8_t * ttl_data
Definition
msgparse.h:181
rrset_parse
Definition
msgparse.h:135
rrset_parse::rrsig_count
size_t rrsig_count
Definition
msgparse.h:165
rrset_parse::size
size_t size
Definition
msgparse.h:159
rrset_parse::dname
uint8_t * dname
Definition
msgparse.h:147
rrset_parse::rrset_bucket_next
struct rrset_parse * rrset_bucket_next
Definition
msgparse.h:137
rrset_parse::rr_first
struct rr_parse * rr_first
Definition
msgparse.h:161
rrset_parse::type
uint16_t type
Definition
msgparse.h:151
rrset_parse::hash
hashvalue_type hash
Definition
msgparse.h:141
rrset_parse::flags
uint32_t flags
Definition
msgparse.h:155
rrset_parse::dname_len
size_t dname_len
Definition
msgparse.h:149
rrset_parse::section
sldns_pkt_section section
Definition
msgparse.h:145
rrset_parse::rrsig_last
struct rr_parse * rrsig_last
Definition
msgparse.h:169
rrset_parse::rrsig_first
struct rr_parse * rrsig_first
Definition
msgparse.h:167
rrset_parse::rr_count
size_t rr_count
Definition
msgparse.h:157
rrset_parse::rrset_class
uint16_t rrset_class
Definition
msgparse.h:153
rrset_parse::rr_last
struct rr_parse * rr_last
Definition
msgparse.h:163
rrset_parse::rrset_all_next
struct rrset_parse * rrset_all_next
Definition
msgparse.h:139
sldns_buffer
Definition
sbuffer.h:117
external
unbound
util
data
msgparse.h
Generated on
for Electroneum by
1.17.0