Electroneum
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
66#include "sldns/pkthdr.h"
67#include "sldns/rrdef.h"
68struct sldns_buffer;
69struct rrset_parse;
70struct rr_parse;
71struct regional;
72struct edns_option;
73
75#define PARSE_TABLE_SIZE 32
77extern time_t MAX_TTL;
79extern time_t MIN_TTL;
81extern time_t MAX_NEG_TTL;
83#define NORR_TTL 5 /* seconds */
84
131
171
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
223
237
245
254int parse_packet(struct sldns_buffer* pkt, struct msg_parse* msg,
255 struct regional* region);
256
274int parse_extract_edns(struct msg_parse* msg, struct edns_data* edns,
275 struct regional* region);
276
287int parse_edns_from_pkt(struct sldns_buffer* pkt, struct edns_data* edns,
288 struct regional* region);
289
300 uint16_t type, uint16_t dclass, uint32_t rrset_flags);
301
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
323void msgparse_bucket_remove(struct msg_parse* msg, struct rrset_parse* rrset);
324
331void 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
Definition log.h:49
uint32_t hashvalue_type
Definition lruhash.h:119
hashvalue_type pkt_hash_rrset(struct sldns_buffer *pkt, uint8_t *dname, uint16_t type, uint16_t dclass, uint32_t rrset_flags)
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)
int parse_extract_edns(struct msg_parse *msg, struct edns_data *edns, struct regional *region)
time_t MAX_NEG_TTL
#define PARSE_TABLE_SIZE
Definition msgparse.h:75
int parse_packet(struct sldns_buffer *pkt, struct msg_parse *msg, struct regional *region)
size_t get_rdf_size(sldns_rdf_type rdf)
time_t MAX_TTL
time_t MIN_TTL
void msgparse_bucket_remove(struct msg_parse *msg, struct rrset_parse *rrset)
int parse_edns_from_pkt(struct sldns_buffer *pkt, struct edns_data *edns, struct regional *region)
void log_edns_opt_list(enum verbosity_value level, const char *info_str, struct edns_option *list)
enum sldns_enum_pkt_section sldns_pkt_section
Definition pkthdr.h:126
enum sldns_enum_rdf_type sldns_rdf_type
Definition rrdef.h:360
unsigned short uint16_t
Definition stdint.h:125
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
uint8_t ext_rcode
Definition msgparse.h:213
struct edns_option * opt_list
Definition msgparse.h:221
uint16_t bits
Definition msgparse.h:217
uint8_t edns_version
Definition msgparse.h:215
uint16_t udp_size
Definition msgparse.h:219
int edns_present
Definition msgparse.h:211
uint8_t * opt_data
Definition msgparse.h:235
uint16_t opt_code
Definition msgparse.h:231
size_t opt_len
Definition msgparse.h:233
struct edns_option * next
Definition msgparse.h:229
uint8_t * qname
Definition msgparse.h:112
uint16_t nscount
Definition msgparse.h:99
uint16_t ancount
Definition msgparse.h:97
uint16_t qtype
Definition msgparse.h:116
size_t an_rrsets
Definition msgparse.h:103
uint16_t flags
Definition msgparse.h:93
uint16_t id
Definition msgparse.h:91
uint16_t arcount
Definition msgparse.h:101
uint16_t qclass
Definition msgparse.h:118
size_t rrset_count
Definition msgparse.h:109
size_t ar_rrsets
Definition msgparse.h:107
size_t ns_rrsets
Definition msgparse.h:105
struct rrset_parse * rrset_first
Definition msgparse.h:127
size_t qname_len
Definition msgparse.h:114
struct rrset_parse * hashtable[PARSE_TABLE_SIZE]
Definition msgparse.h:124
struct rrset_parse * rrset_last
Definition msgparse.h:129
uint16_t qdcount
Definition msgparse.h:95
struct rr_parse * next
Definition msgparse.h:188
size_t size
Definition msgparse.h:186
int outside_packet
Definition msgparse.h:184
uint8_t * ttl_data
Definition msgparse.h:181
size_t rrsig_count
Definition msgparse.h:165
size_t size
Definition msgparse.h:159
uint8_t * dname
Definition msgparse.h:147
struct rrset_parse * rrset_bucket_next
Definition msgparse.h:137
struct rr_parse * rr_first
Definition msgparse.h:161
uint16_t type
Definition msgparse.h:151
hashvalue_type hash
Definition msgparse.h:141
uint32_t flags
Definition msgparse.h:155
size_t dname_len
Definition msgparse.h:149
sldns_pkt_section section
Definition msgparse.h:145
struct rr_parse * rrsig_last
Definition msgparse.h:169
struct rr_parse * rrsig_first
Definition msgparse.h:167
size_t rr_count
Definition msgparse.h:157
uint16_t rrset_class
Definition msgparse.h:153
struct rr_parse * rr_last
Definition msgparse.h:163
struct rrset_parse * rrset_all_next
Definition msgparse.h:139