OpenDNSSEC-signer  2.1.5
query.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 NLNet Labs. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
32 #ifndef WIRE_QUERY_H
33 #define WIRE_QUERY_H
34 
35 #include "config.h"
36 #include "status.h"
37 #include "signer/zone.h"
38 #include "wire/buffer.h"
39 #include "wire/edns.h"
40 #include "wire/tsig.h"
41 
42 #define UDP_MAX_MESSAGE_LEN 512
43 #define TCP_MAX_MESSAGE_LEN 65535
44 #define QUERY_RESPONSE_MAX_RRSET 10 /* should be enough */
45 
46 enum query_enum {
51 };
52 typedef enum query_enum query_state;
53 
58 typedef struct query_struct query_type;
59 struct query_struct {
60  /* Query from addres */
61  struct sockaddr_storage addr;
62  socklen_t addrlen;
63  /* Maximum supported query size */
64  size_t maxlen;
66  /* TSIG */
68  /* EDNS */
70  /* TCP */
71  int tcp;
72  uint16_t tcplen;
74  /* QNAME, QTYPE, QCLASS */
75 
76  /* Zone */
78  /* Compression */
79 
80  /* AXFR IXFR */
81  FILE* axfr_fd;
82  uint32_t serial;
83  size_t startpos;
84  /* Bits */
85  unsigned axfr_is_done : 1;
86  unsigned tsig_prepare_it : 1;
87  unsigned tsig_update_it : 1;
88  unsigned tsig_sign_it : 1;
89 };
90 
97  size_t rrset_count;
100 };
101 
107 query_type* query_create(void);
108 
114 void query_prepare(query_type* q);
115 
124 
132 void query_reset(query_type* q, size_t maxlen, int is_tcp);
133 
140 void query_add_optional(query_type* q, engine_type* engine);
141 
149 int query_add_rr(query_type* q, ldns_rr* rr);
150 
156 void query_cleanup(query_type* q);
157 
158 #endif /* WIRE_QUERY_H */
QUERY_DISCARDED
@ QUERY_DISCARDED
Definition: query.h:48
query_struct::addrlen
socklen_t addrlen
Definition: query.h:62
query_struct::axfr_is_done
unsigned axfr_is_done
Definition: query.h:85
query_create
query_type * query_create(void)
Definition: query.c:48
QUERY_PROCESSED
@ QUERY_PROCESSED
Definition: query.h:47
query_struct::tcp
int tcp
Definition: query.h:71
query_prepare
void query_prepare(query_type *q)
Definition: query.c:612
query_state
enum query_enum query_state
Definition: query.h:52
QUERY_RESPONSE_MAX_RRSET
#define QUERY_RESPONSE_MAX_RRSET
Definition: query.h:44
zone_struct
Definition: zone.h:60
query_struct::axfr_fd
FILE * axfr_fd
Definition: query.h:81
rrset_struct
Definition: rrset.h:59
tsig_rr_struct
Definition: tsig.h:123
zone.h
QUERY_AXFR
@ QUERY_AXFR
Definition: query.h:49
edns.h
query_struct::edns_rr
edns_rr_type * edns_rr
Definition: query.h:69
response_struct::sections
ldns_pkt_section sections[QUERY_RESPONSE_MAX_RRSET]
Definition: query.h:98
response_struct::rrset_count
size_t rrset_count
Definition: query.h:97
query_cleanup
void query_cleanup(query_type *q)
Definition: query.c:1092
query_add_optional
void query_add_optional(query_type *q, engine_type *engine)
Definition: query.c:956
query_struct::tsig_update_it
unsigned tsig_update_it
Definition: query.h:87
query_struct::tcplen
uint16_t tcplen
Definition: query.h:72
response_struct
Definition: query.h:96
query_process
query_state query_process(query_type *q, engine_type *engine)
Definition: query.c:842
query_struct::reserved_space
size_t reserved_space
Definition: query.h:65
buffer_struct
Definition: buffer.h:112
QUERY_IXFR
@ QUERY_IXFR
Definition: query.h:50
tsig.h
buffer.h
query_struct::maxlen
size_t maxlen
Definition: query.h:64
query_struct::tsig_prepare_it
unsigned tsig_prepare_it
Definition: query.h:86
engine_struct
Definition: engine.h:51
edns_rr_struct
Definition: edns.h:76
query_struct::serial
uint32_t serial
Definition: query.h:82
query_struct::buffer
buffer_type * buffer
Definition: query.h:73
query_struct::startpos
size_t startpos
Definition: query.h:83
response_struct::rrsets
rrset_type * rrsets[QUERY_RESPONSE_MAX_RRSET]
Definition: query.h:99
query_add_rr
int query_add_rr(query_type *q, ldns_rr *rr)
Definition: query.c:1035
query_struct::addr
struct sockaddr_storage addr
Definition: query.h:61
query_struct
Definition: query.h:59
query_struct::zone
zone_type * zone
Definition: query.h:77
query_reset
void query_reset(query_type *q, size_t maxlen, int is_tcp)
Definition: query.c:80
query_struct::tsig_rr
tsig_rr_type * tsig_rr
Definition: query.h:67
query_enum
query_enum
Definition: query.h:46
query_struct::tsig_sign_it
unsigned tsig_sign_it
Definition: query.h:88