OpenDNSSEC-signer  1.4.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 "shared/allocator.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  /* Memory allocator */
62  /* Query from addres */
63  struct sockaddr_storage addr;
64  socklen_t addrlen;
65  /* Maximum supported query size */
66  size_t maxlen;
68  /* TSIG */
70  /* EDNS */
72  /* TCP */
73  int tcp;
74  uint16_t tcplen;
76  /* QNAME, QTYPE, QCLASS */
77 
78  /* Zone */
80  /* Compression */
81 
82  /* AXFR IXFR */
83  FILE* axfr_fd;
84  uint32_t serial;
85  size_t startpos;
86  /* Bits */
87  unsigned axfr_is_done : 1;
88  unsigned tsig_prepare_it : 1;
89  unsigned tsig_update_it : 1;
90  unsigned tsig_sign_it : 1;
91 };
92 
99  size_t rrset_count;
102 };
103 
109 query_type* query_create(void);
110 
116 void query_prepare(query_type* q);
117 
125 query_state query_process(query_type* q, void* engine);
126 
134 void query_reset(query_type* q, size_t maxlen, int is_tcp);
135 
142 void query_add_optional(query_type* q, void* engine);
143 
151 int query_add_rr(query_type* q, ldns_rr* rr);
152 
158 void query_cleanup(query_type* q);
159 
160 #endif /* WIRE_QUERY_H */
void query_prepare(query_type *q)
Definition: query.c:579
size_t maxlen
Definition: query.h:66
uint16_t tcplen
Definition: query.h:74
int query_add_rr(query_type *q, ldns_rr *rr)
Definition: query.c:1006
unsigned tsig_sign_it
Definition: query.h:90
int tcp
Definition: query.h:73
tsig_rr_type * tsig_rr
Definition: query.h:69
zone_type * zone
Definition: query.h:79
unsigned tsig_update_it
Definition: query.h:89
void query_add_optional(query_type *q, void *engine)
Definition: query.c:925
size_t rrset_count
Definition: query.h:99
query_type * query_create(void)
Definition: query.c:48
size_t reserved_space
Definition: query.h:67
edns_rr_type * edns_rr
Definition: query.h:71
void query_cleanup(query_type *q)
Definition: query.c:1063
unsigned tsig_prepare_it
Definition: query.h:88
struct sockaddr_storage addr
Definition: query.h:63
rrset_type * rrsets[QUERY_RESPONSE_MAX_RRSET]
Definition: query.h:101
query_enum
Definition: query.h:46
allocator_type * allocator
Definition: query.h:61
void query_reset(query_type *q, size_t maxlen, int is_tcp)
Definition: query.c:90
uint32_t serial
Definition: query.h:84
enum query_enum query_state
Definition: query.h:52
buffer_type * buffer
Definition: query.h:75
size_t startpos
Definition: query.h:85
unsigned axfr_is_done
Definition: query.h:87
socklen_t addrlen
Definition: query.h:64
FILE * axfr_fd
Definition: query.h:83
#define QUERY_RESPONSE_MAX_RRSET
Definition: query.h:44
ldns_pkt_section sections[QUERY_RESPONSE_MAX_RRSET]
Definition: query.h:100
query_state query_process(query_type *q, void *engine)
Definition: query.c:810