Electroneum
Loading...
Searching...
No Matches
outside_network.h
Go to the documentation of this file.
1/*
2 * services/outside_network.h - listen to answers from the network
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 */
35
42
43#ifndef OUTSIDE_NETWORK_H
44#define OUTSIDE_NETWORK_H
45
46#include "util/rbtree.h"
47#include "util/netevent.h"
48#include "dnstap/dnstap_config.h"
49struct pending;
50struct pending_timeout;
51struct ub_randstate;
52struct pending_tcp;
53struct waiting_tcp;
54struct waiting_udp;
55struct infra_cache;
56struct port_comm;
57struct port_if;
58struct sldns_buffer;
59struct serviced_query;
60struct dt_env;
61struct edns_option;
62struct module_env;
63struct module_qstate;
64struct query_info;
65
72 struct comm_base* base;
74 time_t* now_secs;
76 struct timeval* now_tv;
77
88
96 void (*unwanted_action)(void*);
99
108 struct timeval delay_tv;
109
114
119
124
132 struct ub_randstate* rnd;
134 void* sslctx;
135#ifdef USE_DNSTAP
137 struct dt_env* dtenv;
138#endif
141
150 size_t num_tcp;
159};
160
165struct port_if {
169 socklen_t addrlen;
170
174
180
183 struct port_comm** out;
187 int inuse;
188};
189
193struct port_comm {
199 struct port_if* pif;
201 int index;
205 struct comm_point* cp;
206};
207
211struct pending {
217 unsigned int id;
221 socklen_t addrlen;
223 struct port_comm* pc;
229 void* cb_arg;
234
235 /*---- filled if udp pending is waiting -----*/
243 size_t pkt_len;
244};
245
259
296
308
310#define EDNS_FRAG_SIZE_IP4 1472
312#define EDNS_FRAG_SIZE_IP6 1232
313
392
421 size_t bufsize, size_t num_ports, char** ifs, int num_ifs,
422 int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache* infra,
423 struct ub_randstate* rnd, int use_caps_for_id, int* availports,
424 int numavailports, size_t unwanted_threshold, int tcp_mss,
425 void (*unwanted_action)(void*), void* unwanted_param, int do_udp,
426 void* sslctx, int delayclose, struct dt_env *dtenv);
427
433
439
451 struct sldns_buffer* packet, int timeout, comm_point_callback_type* callback,
452 void* callback_arg);
453
467 struct sldns_buffer* packet, int timeout, comm_point_callback_type* callback,
468 void* callback_arg);
469
477
510 struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec,
511 int nocaps, int tcp_upstream, int ssl_upstream, char* tls_auth_name,
512 struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
513 size_t zonelen, struct module_qstate* qstate,
514 comm_point_callback_type* callback, void* callback_arg,
515 struct sldns_buffer* buff, struct module_env* env);
516
524void outnet_serviced_query_stop(struct serviced_query* sq, void* cb_arg);
525
533
542
545int outnet_get_tcp_fd(struct sockaddr_storage* addr, socklen_t addrlen, int tcp_mss);
546
559 struct sockaddr_storage* to_addr, socklen_t to_addrlen);
560
579 struct sockaddr_storage* to_addr, socklen_t to_addrlen,
580 struct sldns_buffer* query, int timeout);
581
601 struct sockaddr_storage* to_addr, socklen_t to_addrlen, int timeout,
602 int ssl, char* host, char* path);
603
605int outnet_tcp_connect(int s, struct sockaddr_storage* addr, socklen_t addrlen);
606
608int outnet_udp_cb(struct comm_point* c, void* arg, int error,
609 struct comm_reply *reply_info);
610
612int outnet_tcp_cb(struct comm_point* c, void* arg, int error,
613 struct comm_reply *reply_info);
614
616void pending_udp_timer_cb(void *arg);
617
620
622void outnet_tcptimer(void* arg);
623
625int serviced_udp_callback(struct comm_point* c, void* arg, int error,
626 struct comm_reply* rep);
627
629int serviced_tcp_callback(struct comm_point* c, void* arg, int error,
630 struct comm_reply* rep);
631
633int pending_cmp(const void* key1, const void* key2);
634
636int serviced_cmp(const void* key1, const void* key2);
637
638#endif /* OUTSIDE_NETWORK_H */
int comm_point_callback_type(struct comm_point *, void *, int, struct comm_reply *)
Definition netevent.h:76
struct comm_point * outnet_comm_point_for_udp(struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *to_addr, socklen_t to_addrlen)
int pending_cmp(const void *key1, const void *key2)
size_t outnet_get_mem(struct outside_network *outnet)
struct comm_point * outnet_comm_point_for_tcp(struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *to_addr, socklen_t to_addrlen, struct sldns_buffer *query, int timeout)
void outnet_tcptimer(void *arg)
void outside_network_quit_prepare(struct outside_network *outnet)
int outnet_tcp_cb(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
struct waiting_tcp * pending_tcp_query(struct serviced_query *sq, struct sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg)
int serviced_cmp(const void *key1, const void *key2)
size_t serviced_get_mem(struct serviced_query *sq)
void pending_delete(struct outside_network *outnet, struct pending *p)
int serviced_tcp_callback(struct comm_point *c, void *arg, int error, struct comm_reply *rep)
int outnet_get_tcp_fd(struct sockaddr_storage *addr, socklen_t addrlen, int tcp_mss)
int outnet_udp_cb(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
struct pending * pending_udp_query(struct serviced_query *sq, struct sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg)
void pending_udp_timer_cb(void *arg)
void pending_udp_timer_delay_cb(void *arg)
struct comm_point * outnet_comm_point_for_http(struct outside_network *outnet, comm_point_callback_type *cb, void *cb_arg, struct sockaddr_storage *to_addr, socklen_t to_addrlen, int timeout, int ssl, char *host, char *path)
int serviced_udp_callback(struct comm_point *c, void *arg, int error, struct comm_reply *rep)
struct serviced_query * outnet_serviced_query(struct outside_network *outnet, struct query_info *qinfo, uint16_t flags, int dnssec, int want_dnssec, int nocaps, int tcp_upstream, int ssl_upstream, char *tls_auth_name, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, struct module_qstate *qstate, comm_point_callback_type *callback, void *callback_arg, struct sldns_buffer *buff, struct module_env *env)
struct outside_network * outside_network_create(struct comm_base *base, size_t bufsize, size_t num_ports, char **ifs, int num_ifs, int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache *infra, struct ub_randstate *rnd, int use_caps_for_id, int *availports, int numavailports, size_t unwanted_threshold, int tcp_mss, void(*unwanted_action)(void *), void *unwanted_param, int do_udp, void *sslctx, int delayclose, struct dt_env *dtenv)
void outside_network_delete(struct outside_network *outnet)
int outnet_tcp_connect(int s, struct sockaddr_storage *addr, socklen_t addrlen)
void outnet_serviced_query_stop(struct serviced_query *sq, void *cb_arg)
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
void * ssl
Definition netevent.h:191
void * cb_arg
Definition netevent.h:303
struct timeval * timeout
Definition netevent.h:162
struct waiting_tcp * tcp_wait_first
struct port_comm * unused_fds
struct port_if * ip4_ifs
struct timeval delay_tv
struct timeval * now_tv
struct pending * udp_wait_first
void(* unwanted_action)(void *)
rbtree_type * pending
struct pending * udp_wait_last
struct pending_tcp ** tcp_conns
rbtree_type * serviced
struct sldns_buffer * udp_buff
struct waiting_tcp * tcp_wait_last
struct pending_tcp * tcp_free
struct port_if * ip6_ifs
struct comm_base * base
struct infra_cache * infra
struct ub_randstate * rnd
struct pending_tcp * next_free
struct comm_point * c
struct waiting_tcp * query
uint8_t * pkt
unsigned int id
struct pending * next_waiting
size_t pkt_len
socklen_t addrlen
struct comm_timer * timer
struct serviced_query * sq
struct outside_network * outnet
rbnode_type node
void * cb_arg
struct sockaddr_storage addr
comm_point_callback_type * cb
struct port_comm * pc
struct comm_point * cp
struct port_if * pif
struct port_comm * next
socklen_t addrlen
struct sockaddr_storage addr
struct port_comm ** out
int * avail_ports
struct service_callback * next
comm_point_callback_type * cb
enum serviced_query::serviced_query_status status
struct edns_option * opt_list
struct service_callback * cblist
struct timeval last_sent_time
struct sockaddr_storage addr
struct outside_network * outnet
socklen_t addrlen
struct comm_timer * timer
struct waiting_tcp * next_waiting
struct outside_network * outnet
comm_point_callback_type * cb
struct sockaddr_storage addr