xref: /freebsd/contrib/unbound/services/outside_network.h (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
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 
36 /**
37  * \file
38  *
39  * This file has functions to send queries to authoritative servers,
40  * and wait for the pending answer, with timeouts.
41  */
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"
49 struct pending;
50 struct pending_timeout;
51 struct ub_randstate;
52 struct pending_tcp;
53 struct waiting_tcp;
54 struct waiting_udp;
55 struct infra_cache;
56 struct port_comm;
57 struct port_if;
58 struct sldns_buffer;
59 struct serviced_query;
60 struct dt_env;
61 struct edns_option;
62 struct module_env;
63 struct module_qstate;
64 struct query_info;
65 
66 /**
67  * Send queries to outside servers and wait for answers from servers.
68  * Contains answer-listen sockets.
69  */
70 struct outside_network {
71 	/** Base for select calls */
72 	struct comm_base* base;
73 	/** pointer to time in seconds */
74 	time_t* now_secs;
75 	/** pointer to time in microseconds */
76 	struct timeval* now_tv;
77 
78 	/** buffer shared by UDP connections, since there is only one
79 	    datagram at any time. */
80 	struct sldns_buffer* udp_buff;
81 	/** serviced_callbacks malloc overhead when processing multiple
82 	 * identical serviced queries to the same server. */
83 	size_t svcd_overhead;
84 	/** use x20 bits to encode additional ID random bits */
85 	int use_caps_for_id;
86 	/** outside network wants to quit. Stop queued msgs from sent. */
87 	int want_to_quit;
88 
89 	/** number of unwanted replies received (for statistics) */
90 	size_t unwanted_replies;
91 	/** cumulative total of unwanted replies (for defense) */
92 	size_t unwanted_total;
93 	/** threshold when to take defensive action. If 0 then never. */
94 	size_t unwanted_threshold;
95 	/** what action to take, called when defensive action is needed */
96 	void (*unwanted_action)(void*);
97 	/** user param for action */
98 	void* unwanted_param;
99 
100 	/** linked list of available commpoints, unused file descriptors,
101 	 * for use as outgoing UDP ports. cp.fd=-1 in them. */
102 	struct port_comm* unused_fds;
103 	/** if udp is done */
104 	int do_udp;
105 	/** if udp is delay-closed (delayed answers do not meet closed port)*/
106 	int delayclose;
107 	/** timeout for delayclose */
108 	struct timeval delay_tv;
109 
110 	/** array of outgoing IP4 interfaces */
111 	struct port_if* ip4_ifs;
112 	/** number of outgoing IP4 interfaces */
113 	int num_ip4;
114 
115 	/** array of outgoing IP6 interfaces */
116 	struct port_if* ip6_ifs;
117 	/** number of outgoing IP6 interfaces */
118 	int num_ip6;
119 
120 	/** pending udp queries waiting to be sent out, waiting for fd */
121 	struct pending* udp_wait_first;
122 	/** last pending udp query in list */
123 	struct pending* udp_wait_last;
124 
125 	/** pending udp answers. sorted by id, addr */
126 	rbtree_type* pending;
127 	/** serviced queries, sorted by qbuf, addr, dnssec */
128 	rbtree_type* serviced;
129 	/** host cache, pointer but not owned by outnet. */
130 	struct infra_cache* infra;
131 	/** where to get random numbers */
132 	struct ub_randstate* rnd;
133 	/** ssl context to create ssl wrapped TCP with DNS connections */
134 	void* sslctx;
135 #ifdef USE_DNSTAP
136 	/** dnstap environment */
137 	struct dt_env* dtenv;
138 #endif
139 	/** maximum segment size of tcp socket */
140 	int tcp_mss;
141 
142 	/**
143 	 * Array of tcp pending used for outgoing TCP connections.
144 	 * Each can be used to establish a TCP connection with a server.
145 	 * The file descriptors are -1 if they are free, and need to be
146 	 * opened for the tcp connection. Can be used for ip4 and ip6.
147 	 */
148 	struct pending_tcp **tcp_conns;
149 	/** number of tcp communication points. */
150 	size_t num_tcp;
151 	/** number of tcp communication points in use. */
152 	size_t num_tcp_outgoing;
153 	/** list of tcp comm points that are free for use */
154 	struct pending_tcp* tcp_free;
155 	/** list of tcp queries waiting for a buffer */
156 	struct waiting_tcp* tcp_wait_first;
157 	/** last of waiting query list */
158 	struct waiting_tcp* tcp_wait_last;
159 };
160 
161 /**
162  * Outgoing interface. Ports available and currently used are tracked
163  * per interface
164  */
165 struct port_if {
166 	/** address ready to allocate new socket (except port no). */
167 	struct sockaddr_storage addr;
168 	/** length of addr field */
169 	socklen_t addrlen;
170 
171 	/** prefix length of network address (in bits), for randomisation.
172 	 * if 0, no randomisation. */
173 	int pfxlen;
174 
175 	/** the available ports array. These are unused.
176 	 * Only the first total-inuse part is filled. */
177 	int* avail_ports;
178 	/** the total number of available ports (size of the array) */
179 	int avail_total;
180 
181 	/** array of the commpoints currently in use.
182 	 * allocated for max number of fds, first part in use. */
183 	struct port_comm** out;
184 	/** max number of fds, size of out array */
185 	int maxout;
186 	/** number of commpoints (and thus also ports) in use */
187 	int inuse;
188 };
189 
190 /**
191  * Outgoing commpoint for UDP port.
192  */
193 struct port_comm {
194 	/** next in free list */
195 	struct port_comm* next;
196 	/** which port number (when in use) */
197 	int number;
198 	/** interface it is used in */
199 	struct port_if* pif;
200 	/** index in the out array of the interface */
201 	int index;
202 	/** number of outstanding queries on this port */
203 	int num_outstanding;
204 	/** UDP commpoint, fd=-1 if not in use */
205 	struct comm_point* cp;
206 };
207 
208 /**
209  * A query that has an answer pending for it.
210  */
211 struct pending {
212 	/** redblacktree entry, key is the pending struct(id, addr). */
213 	rbnode_type node;
214 	/** the ID for the query. int so that a value out of range can
215 	 * be used to signify a pending that is for certain not present in
216 	 * the rbtree. (and for which deletion is safe). */
217 	unsigned int id;
218 	/** remote address. */
219 	struct sockaddr_storage addr;
220 	/** length of addr field in use. */
221 	socklen_t addrlen;
222 	/** comm point it was sent on (and reply must come back on). */
223 	struct port_comm* pc;
224 	/** timeout event */
225 	struct comm_timer* timer;
226 	/** callback for the timeout, error or reply to the message */
227 	comm_point_callback_type* cb;
228 	/** callback user argument */
229 	void* cb_arg;
230 	/** the outside network it is part of */
231 	struct outside_network* outnet;
232 	/** the corresponding serviced_query */
233 	struct serviced_query* sq;
234 
235 	/*---- filled if udp pending is waiting -----*/
236 	/** next in waiting list. */
237 	struct pending* next_waiting;
238 	/** timeout in msec */
239 	int timeout;
240 	/** The query itself, the query packet to send. */
241 	uint8_t* pkt;
242 	/** length of query packet. */
243 	size_t pkt_len;
244 };
245 
246 /**
247  * Pending TCP query to server.
248  */
249 struct pending_tcp {
250 	/** next in list of free tcp comm points, or NULL. */
251 	struct pending_tcp* next_free;
252 	/** the ID for the query; checked in reply */
253 	uint16_t id;
254 	/** tcp comm point it was sent on (and reply must come back on). */
255 	struct comm_point* c;
256 	/** the query being serviced, NULL if the pending_tcp is unused. */
257 	struct waiting_tcp* query;
258 };
259 
260 /**
261  * Query waiting for TCP buffer.
262  */
263 struct waiting_tcp {
264 	/**
265 	 * next in waiting list.
266 	 * if pkt==0, this points to the pending_tcp structure.
267 	 */
268 	struct waiting_tcp* next_waiting;
269 	/** timeout event; timer keeps running whether the query is
270 	 * waiting for a buffer or the tcp reply is pending */
271 	struct comm_timer* timer;
272 	/** the outside network it is part of */
273 	struct outside_network* outnet;
274 	/** remote address. */
275 	struct sockaddr_storage addr;
276 	/** length of addr field in use. */
277 	socklen_t addrlen;
278 	/**
279 	 * The query itself, the query packet to send.
280 	 * allocated after the waiting_tcp structure.
281 	 * set to NULL when the query is serviced and it part of pending_tcp.
282 	 * if this is NULL, the next_waiting points to the pending_tcp.
283 	 */
284 	uint8_t* pkt;
285 	/** length of query packet. */
286 	size_t pkt_len;
287 	/** callback for the timeout, error or reply to the message */
288 	comm_point_callback_type* cb;
289 	/** callback user argument */
290 	void* cb_arg;
291 	/** if it uses ssl upstream */
292 	int ssl_upstream;
293 	/** ref to the tls_auth_name from the serviced_query */
294 	char* tls_auth_name;
295 };
296 
297 /**
298  * Callback to party interested in serviced query results.
299  */
300 struct service_callback {
301 	/** next in callback list */
302 	struct service_callback* next;
303 	/** callback function */
304 	comm_point_callback_type* cb;
305 	/** user argument for callback function */
306 	void* cb_arg;
307 };
308 
309 /** fallback size for fragmentation for EDNS in IPv4 */
310 #define EDNS_FRAG_SIZE_IP4 1472
311 /** fallback size for EDNS in IPv6, fits one fragment with ip6-tunnel-ids */
312 #define EDNS_FRAG_SIZE_IP6 1232
313 
314 /**
315  * Query service record.
316  * Contains query and destination. UDP, TCP, EDNS are all tried.
317  * complete with retries and timeouts. A number of interested parties can
318  * receive a callback.
319  */
320 struct serviced_query {
321 	/** The rbtree node, key is this record */
322 	rbnode_type node;
323 	/** The query that needs to be answered. Starts with flags u16,
324 	 * then qdcount, ..., including qname, qtype, qclass. Does not include
325 	 * EDNS record. */
326 	uint8_t* qbuf;
327 	/** length of qbuf. */
328 	size_t qbuflen;
329 	/** If an EDNS section is included, the DO/CD bit will be turned on. */
330 	int dnssec;
331 	/** We want signatures, or else the answer is likely useless */
332 	int want_dnssec;
333 	/** ignore capsforid */
334 	int nocaps;
335 	/** tcp upstream used, use tcp, or ssl_upstream for SSL */
336 	int tcp_upstream, ssl_upstream;
337 	/** the name of the tls authentication name, eg. 'ns.example.com'
338 	 * or NULL */
339 	char* tls_auth_name;
340 	/** where to send it */
341 	struct sockaddr_storage addr;
342 	/** length of addr field in use. */
343 	socklen_t addrlen;
344 	/** zone name, uncompressed domain name in wireformat */
345 	uint8_t* zone;
346 	/** length of zone name */
347 	size_t zonelen;
348 	/** qtype */
349 	int qtype;
350 	/** current status */
351 	enum serviced_query_status {
352 		/** initial status */
353 		serviced_initial,
354 		/** UDP with EDNS sent */
355 		serviced_query_UDP_EDNS,
356 		/** UDP without EDNS sent */
357 		serviced_query_UDP,
358 		/** TCP with EDNS sent */
359 		serviced_query_TCP_EDNS,
360 		/** TCP without EDNS sent */
361 		serviced_query_TCP,
362 		/** probe to test noEDNS0 (EDNS gives FORMERRorNOTIMP) */
363 		serviced_query_UDP_EDNS_fallback,
364 		/** probe to test TCP noEDNS0 (EDNS gives FORMERRorNOTIMP) */
365 		serviced_query_TCP_EDNS_fallback,
366 		/** send UDP query with EDNS1480 (or 1280) */
367 		serviced_query_UDP_EDNS_FRAG
368 	}
369 		/** variable with current status */
370 		status;
371 	/** true if serviced_query is scheduled for deletion already */
372 	int to_be_deleted;
373 	/** number of UDP retries */
374 	int retry;
375 	/** time last UDP was sent */
376 	struct timeval last_sent_time;
377 	/** rtt of last message */
378 	int last_rtt;
379 	/** do we know edns probe status already, for UDP_EDNS queries */
380 	int edns_lame_known;
381 	/** edns options to use for sending upstream packet */
382 	struct edns_option* opt_list;
383 	/** outside network this is part of */
384 	struct outside_network* outnet;
385 	/** list of interested parties that need callback on results. */
386 	struct service_callback* cblist;
387 	/** the UDP or TCP query that is pending, see status which */
388 	void* pending;
389 };
390 
391 /**
392  * Create outside_network structure with N udp ports.
393  * @param base: the communication base to use for event handling.
394  * @param bufsize: size for network buffers.
395  * @param num_ports: number of udp ports to open per interface.
396  * @param ifs: interface names (or NULL for default interface).
397  *    These interfaces must be able to access all authoritative servers.
398  * @param num_ifs: number of names in array ifs.
399  * @param do_ip4: service IP4.
400  * @param do_ip6: service IP6.
401  * @param num_tcp: number of outgoing tcp buffers to preallocate.
402  * @param infra: pointer to infra cached used for serviced queries.
403  * @param rnd: stored to create random numbers for serviced queries.
404  * @param use_caps_for_id: enable to use 0x20 bits to encode id randomness.
405  * @param availports: array of available ports.
406  * @param numavailports: number of available ports in array.
407  * @param unwanted_threshold: when to take defensive action.
408  * @param unwanted_action: the action to take.
409  * @param unwanted_param: user parameter to action.
410  * @param tcp_mss: maximum segment size of tcp socket.
411  * @param do_udp: if udp is done.
412  * @param sslctx: context to create outgoing connections with (if enabled).
413  * @param delayclose: if not 0, udp sockets are delayed before timeout closure.
414  * 	msec to wait on timeouted udp sockets.
415  * @param dtenv: environment to send dnstap events with (if enabled).
416  * @return: the new structure (with no pending answers) or NULL on error.
417  */
418 struct outside_network* outside_network_create(struct comm_base* base,
419 	size_t bufsize, size_t num_ports, char** ifs, int num_ifs,
420 	int do_ip4, int do_ip6, size_t num_tcp, struct infra_cache* infra,
421 	struct ub_randstate* rnd, int use_caps_for_id, int* availports,
422 	int numavailports, size_t unwanted_threshold, int tcp_mss,
423 	void (*unwanted_action)(void*), void* unwanted_param, int do_udp,
424 	void* sslctx, int delayclose, struct dt_env *dtenv);
425 
426 /**
427  * Delete outside_network structure.
428  * @param outnet: object to delete.
429  */
430 void outside_network_delete(struct outside_network* outnet);
431 
432 /**
433  * Prepare for quit. Sends no more queries, even if queued up.
434  * @param outnet: object to prepare for removal
435  */
436 void outside_network_quit_prepare(struct outside_network* outnet);
437 
438 /**
439  * Send UDP query, create pending answer.
440  * Changes the ID for the query to be random and unique for that destination.
441  * @param sq: serviced query.
442  * @param packet: wireformat query to send to destination.
443  * @param timeout: in milliseconds from now.
444  * @param callback: function to call on error, timeout or reply.
445  * @param callback_arg: user argument for callback function.
446  * @return: NULL on error for malloc or socket. Else the pending query object.
447  */
448 struct pending* pending_udp_query(struct serviced_query* sq,
449 	struct sldns_buffer* packet, int timeout, comm_point_callback_type* callback,
450 	void* callback_arg);
451 
452 /**
453  * Send TCP query. May wait for TCP buffer. Selects ID to be random, and
454  * checks id.
455  * @param sq: serviced query.
456  * @param packet: wireformat query to send to destination. copied from.
457  * @param timeout: in milliseconds from now.
458  *    Timer starts running now. Timer may expire if all buffers are used,
459  *    without any query been sent to the server yet.
460  * @param callback: function to call on error, timeout or reply.
461  * @param callback_arg: user argument for callback function.
462  * @return: false on error for malloc or socket. Else the pending TCP object.
463  */
464 struct waiting_tcp* pending_tcp_query(struct serviced_query* sq,
465 	struct sldns_buffer* packet, int timeout, comm_point_callback_type* callback,
466 	void* callback_arg);
467 
468 /**
469  * Delete pending answer.
470  * @param outnet: outside network the pending query is part of.
471  *    Internal feature: if outnet is NULL, p is not unlinked from rbtree.
472  * @param p: deleted
473  */
474 void pending_delete(struct outside_network* outnet, struct pending* p);
475 
476 /**
477  * Perform a serviced query to the authoritative servers.
478  * Duplicate efforts are detected, and EDNS, TCP and UDP retry is performed.
479  * @param outnet: outside network, with rbtree of serviced queries.
480  * @param qinfo: query info.
481  * @param flags: flags u16 (host format), includes opcode, CD bit.
482  * @param dnssec: if set, DO bit is set in EDNS queries.
483  *	If the value includes BIT_CD, CD bit is set when in EDNS queries.
484  *	If the value includes BIT_DO, DO bit is set when in EDNS queries.
485  * @param want_dnssec: signatures are needed, without EDNS the answer is
486  * 	likely to be useless.
487  * @param nocaps: ignore use_caps_for_id and use unperturbed qname.
488  * @param tcp_upstream: use TCP for upstream queries.
489  * @param ssl_upstream: use SSL for upstream queries.
490  * @param tls_auth_name: when ssl_upstream is true, use this name to check
491  * 	the server's peer certificate.
492  * @param addr: to which server to send the query.
493  * @param addrlen: length of addr.
494  * @param zone: name of the zone of the delegation point. wireformat dname.
495 	This is the delegation point name for which the server is deemed
496 	authoritative.
497  * @param zonelen: length of zone.
498  * @param qstate: module qstate. Mainly for inspecting the available
499  *	edns_opts_lists.
500  * @param callback: callback function.
501  * @param callback_arg: user argument to callback function.
502  * @param buff: scratch buffer to create query contents in. Empty on exit.
503  * @param env: the module environment.
504  * @return 0 on error, or pointer to serviced query that is used to answer
505  *	this serviced query may be shared with other callbacks as well.
506  */
507 struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
508 	struct query_info* qinfo, uint16_t flags, int dnssec, int want_dnssec,
509 	int nocaps, int tcp_upstream, int ssl_upstream, char* tls_auth_name,
510 	struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
511 	size_t zonelen, struct module_qstate* qstate,
512 	comm_point_callback_type* callback, void* callback_arg,
513 	struct sldns_buffer* buff, struct module_env* env);
514 
515 /**
516  * Remove service query callback.
517  * If that leads to zero callbacks, the query is completely cancelled.
518  * @param sq: serviced query to adjust.
519  * @param cb_arg: callback argument of callback that needs removal.
520  *	same as the callback_arg to outnet_serviced_query().
521  */
522 void outnet_serviced_query_stop(struct serviced_query* sq, void* cb_arg);
523 
524 /**
525  * Get memory size in use by outside network.
526  * Counts buffers and outstanding query (serviced queries) malloced data.
527  * @param outnet: outside network structure.
528  * @return size in bytes.
529  */
530 size_t outnet_get_mem(struct outside_network* outnet);
531 
532 /**
533  * Get memory size in use by serviced query while it is servicing callbacks.
534  * This takes into account the pre-deleted status of it; it will be deleted
535  * when the callbacks are done.
536  * @param sq: serviced query.
537  * @return size in bytes.
538  */
539 size_t serviced_get_mem(struct serviced_query* sq);
540 
541 /** get TCP file descriptor for address, returns -1 on failure,
542  * tcp_mss is 0 or maxseg size to set for TCP packets. */
543 int outnet_get_tcp_fd(struct sockaddr_storage* addr, socklen_t addrlen, int tcp_mss);
544 
545 /**
546  * Create udp commpoint suitable for sending packets to the destination.
547  * @param outnet: outside_network with the comm_base it is attached to,
548  * 	with the outgoing interfaces chosen from, and rnd gen for random.
549  * @param cb: callback function for the commpoint.
550  * @param cb_arg: callback argument for cb.
551  * @param to_addr: intended destination.
552  * @param to_addrlen: length of to_addr.
553  * @return commpoint that you can comm_point_send_udp_msg with, or NULL.
554  */
555 struct comm_point* outnet_comm_point_for_udp(struct outside_network* outnet,
556 	comm_point_callback_type* cb, void* cb_arg,
557 	struct sockaddr_storage* to_addr, socklen_t to_addrlen);
558 
559 /**
560  * Create tcp commpoint suitable for communication to the destination.
561  * It also performs connect() to the to_addr.
562  * @param outnet: outside_network with the comm_base it is attached to,
563  * 	and the tcp_mss.
564  * @param cb: callback function for the commpoint.
565  * @param cb_arg: callback argument for cb.
566  * @param to_addr: intended destination.
567  * @param to_addrlen: length of to_addr.
568  * @param query: initial packet to send writing, in buffer.  It is copied
569  * 	to the commpoint buffer that is created.
570  * @param timeout: timeout for the TCP connection.
571  * 	timeout in milliseconds, or -1 for no (change to the) timeout.
572  *	So seconds*1000.
573  * @param ssl: set to true for TLS.
574  * @param host: hostname for host name verification of TLS (or NULL if no TLS).
575  * @return tcp_out commpoint, or NULL.
576  */
577 struct comm_point* outnet_comm_point_for_tcp(struct outside_network* outnet,
578 	comm_point_callback_type* cb, void* cb_arg,
579 	struct sockaddr_storage* to_addr, socklen_t to_addrlen,
580 	struct sldns_buffer* query, int timeout, int ssl, char* host);
581 
582 /**
583  * Create http commpoint suitable for communication to the destination.
584  * Creates the http request buffer. It also performs connect() to the to_addr.
585  * @param outnet: outside_network with the comm_base it is attached to,
586  * 	and the tcp_mss.
587  * @param cb: callback function for the commpoint.
588  * @param cb_arg: callback argument for cb.
589  * @param to_addr: intended destination.
590  * @param to_addrlen: length of to_addr.
591  * @param timeout: timeout for the TCP connection.
592  * 	timeout in milliseconds, or -1 for no (change to the) timeout.
593  *	So seconds*1000.
594  * @param ssl: set to true for https.
595  * @param host: hostname to use for the destination. part of http request.
596  * @param path: pathname to lookup, eg. name of the file on the destination.
597  * @return http_out commpoint, or NULL.
598  */
599 struct comm_point* outnet_comm_point_for_http(struct outside_network* outnet,
600 	comm_point_callback_type* cb, void* cb_arg,
601 	struct sockaddr_storage* to_addr, socklen_t to_addrlen, int timeout,
602 	int ssl, char* host, char* path);
603 
604 /** connect tcp connection to addr, 0 on failure */
605 int outnet_tcp_connect(int s, struct sockaddr_storage* addr, socklen_t addrlen);
606 
607 /** callback for incoming udp answers from the network */
608 int outnet_udp_cb(struct comm_point* c, void* arg, int error,
609 	struct comm_reply *reply_info);
610 
611 /** callback for pending tcp connections */
612 int outnet_tcp_cb(struct comm_point* c, void* arg, int error,
613 	struct comm_reply *reply_info);
614 
615 /** callback for udp timeout */
616 void pending_udp_timer_cb(void *arg);
617 
618 /** callback for udp delay for timeout */
619 void pending_udp_timer_delay_cb(void *arg);
620 
621 /** callback for outgoing TCP timer event */
622 void outnet_tcptimer(void* arg);
623 
624 /** callback for serviced query UDP answers */
625 int serviced_udp_callback(struct comm_point* c, void* arg, int error,
626         struct comm_reply* rep);
627 
628 /** TCP reply or error callback for serviced queries */
629 int serviced_tcp_callback(struct comm_point* c, void* arg, int error,
630         struct comm_reply* rep);
631 
632 /** compare function of pending rbtree */
633 int pending_cmp(const void* key1, const void* key2);
634 
635 /** compare function of serviced query rbtree */
636 int serviced_cmp(const void* key1, const void* key2);
637 
638 #endif /* OUTSIDE_NETWORK_H */
639