|
Electroneum
|

Go to the source code of this file.
Classes | |
| struct | outside_network |
| struct | port_if |
| struct | port_comm |
| struct | pending |
| struct | pending_tcp |
| struct | waiting_tcp |
| struct | service_callback |
| struct | serviced_query |
Macros | |
| #define | EDNS_FRAG_SIZE_IP4 1472 |
| #define | EDNS_FRAG_SIZE_IP6 1232 |
Functions | |
| 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) |
| void | outside_network_quit_prepare (struct outside_network *outnet) |
| struct pending * | pending_udp_query (struct serviced_query *sq, struct sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg) |
| struct waiting_tcp * | pending_tcp_query (struct serviced_query *sq, struct sldns_buffer *packet, int timeout, comm_point_callback_type *callback, void *callback_arg) |
| void | pending_delete (struct outside_network *outnet, struct pending *p) |
| 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) |
| void | outnet_serviced_query_stop (struct serviced_query *sq, void *cb_arg) |
| size_t | outnet_get_mem (struct outside_network *outnet) |
| size_t | serviced_get_mem (struct serviced_query *sq) |
| int | outnet_get_tcp_fd (struct sockaddr_storage *addr, socklen_t addrlen, int tcp_mss) |
| 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) |
| 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) |
| 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 | outnet_tcp_connect (int s, struct sockaddr_storage *addr, socklen_t addrlen) |
| int | outnet_udp_cb (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
| int | outnet_tcp_cb (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
| void | pending_udp_timer_cb (void *arg) |
| void | pending_udp_timer_delay_cb (void *arg) |
| void | outnet_tcptimer (void *arg) |
| int | serviced_udp_callback (struct comm_point *c, void *arg, int error, struct comm_reply *rep) |
| int | serviced_tcp_callback (struct comm_point *c, void *arg, int error, struct comm_reply *rep) |
| int | pending_cmp (const void *key1, const void *key2) |
| int | serviced_cmp (const void *key1, const void *key2) |
This file has functions to send queries to authoritative servers, and wait for the pending answer, with timeouts.
Definition in file outside_network.h.
| #define EDNS_FRAG_SIZE_IP4 1472 |
fallback size for fragmentation for EDNS in IPv4
Definition at line 310 of file outside_network.h.
| #define EDNS_FRAG_SIZE_IP6 1232 |
fallback size for EDNS in IPv6, fits one fragment with ip6-tunnel-ids
Definition at line 312 of file outside_network.h.
| 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 | ||
| ) |
Create http commpoint suitable for communication to the destination. Creates the http request buffer. It also performs connect() to the to_addr.
| outnet | outside_network with the comm_base it is attached to, and the tcp_mss. |
| cb | callback function for the commpoint. |
| cb_arg | callback argument for cb. |
| to_addr | intended destination. |
| to_addrlen | length of to_addr. |
| timeout | timeout for the TCP connection. timeout in milliseconds, or -1 for no (change to the) timeout. So seconds*1000. |
| ssl | set to true for https. |
| host | hostname to use for the destination. part of http request. |
| path | pathname to lookup, eg. name of the file on the destination. |
| 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 | ||
| ) |
Create tcp commpoint suitable for communication to the destination. It also performs connect() to the to_addr.
| outnet | outside_network with the comm_base it is attached to, and the tcp_mss. |
| cb | callback function for the commpoint. |
| cb_arg | callback argument for cb. |
| to_addr | intended destination. |
| to_addrlen | length of to_addr. |
| query | initial packet to send writing, in buffer. It is copied to the commpoint buffer that is created. |
| timeout | timeout for the TCP connection. timeout in milliseconds, or -1 for no (change to the) timeout. So seconds*1000. |
| 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 | ||
| ) |
Create udp commpoint suitable for sending packets to the destination.
| outnet | outside_network with the comm_base it is attached to, with the outgoing interfaces chosen from, and rnd gen for random. |
| cb | callback function for the commpoint. |
| cb_arg | callback argument for cb. |
| to_addr | intended destination. |
| to_addrlen | length of to_addr. |
| size_t outnet_get_mem | ( | struct outside_network * | outnet | ) |
Get memory size in use by outside network. Counts buffers and outstanding query (serviced queries) malloced data.
| outnet | outside network structure. |
| int outnet_get_tcp_fd | ( | struct sockaddr_storage * | addr, |
| socklen_t | addrlen, | ||
| int | tcp_mss | ||
| ) |
get TCP file descriptor for address, returns -1 on failure, tcp_mss is 0 or maxseg size to set for TCP packets.
| 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 | ||
| ) |
Perform a serviced query to the authoritative servers. Duplicate efforts are detected, and EDNS, TCP and UDP retry is performed.
| outnet | outside network, with rbtree of serviced queries. |
| qinfo | query info. |
| flags | flags u16 (host format), includes opcode, CD bit. |
| dnssec | if set, DO bit is set in EDNS queries. If the value includes BIT_CD, CD bit is set when in EDNS queries. If the value includes BIT_DO, DO bit is set when in EDNS queries. |
| want_dnssec | signatures are needed, without EDNS the answer is likely to be useless. |
| nocaps | ignore use_caps_for_id and use unperturbed qname. |
| tcp_upstream | use TCP for upstream queries. |
| ssl_upstream | use SSL for upstream queries. |
| tls_auth_name | when ssl_upstream is true, use this name to check the server's peer certificate. |
| addr | to which server to send the query. |
| addrlen | length of addr. |
| zone | name of the zone of the delegation point. wireformat dname. This is the delegation point name for which the server is deemed authoritative. |
| zonelen | length of zone. |
| qstate | module qstate. Mainly for inspecting the available edns_opts_lists. |
| callback | callback function. |
| callback_arg | user argument to callback function. |
| buff | scratch buffer to create query contents in. Empty on exit. |
| env | the module environment. |
| void outnet_serviced_query_stop | ( | struct serviced_query * | sq, |
| void * | cb_arg | ||
| ) |
Remove service query callback. If that leads to zero callbacks, the query is completely cancelled.
| sq | serviced query to adjust. |
| cb_arg | callback argument of callback that needs removal. same as the callback_arg to outnet_serviced_query(). |
| int outnet_tcp_cb | ( | struct comm_point * | c, |
| void * | arg, | ||
| int | error, | ||
| struct comm_reply * | reply_info | ||
| ) |
callback for pending tcp connections
| int outnet_tcp_connect | ( | int | s, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen | ||
| ) |
connect tcp connection to addr, 0 on failure
| void outnet_tcptimer | ( | void * | arg | ) |
callback for outgoing TCP timer event
| int outnet_udp_cb | ( | struct comm_point * | c, |
| void * | arg, | ||
| int | error, | ||
| struct comm_reply * | reply_info | ||
| ) |
callback for incoming udp answers from the network
| 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(*)(void *) | unwanted_action, | ||
| void * | unwanted_param, | ||
| int | do_udp, | ||
| void * | sslctx, | ||
| int | delayclose, | ||
| struct dt_env * | dtenv | ||
| ) |
Create outside_network structure with N udp ports.
| base | the communication base to use for event handling. |
| bufsize | size for network buffers. |
| num_ports | number of udp ports to open per interface. |
| ifs | interface names (or NULL for default interface). These interfaces must be able to access all authoritative servers. |
| num_ifs | number of names in array ifs. |
| do_ip4 | service IP4. |
| do_ip6 | service IP6. |
| num_tcp | number of outgoing tcp buffers to preallocate. |
| infra | pointer to infra cached used for serviced queries. |
| rnd | stored to create random numbers for serviced queries. |
| use_caps_for_id | enable to use 0x20 bits to encode id randomness. |
| availports | array of available ports. |
| numavailports | number of available ports in array. |
| unwanted_threshold | when to take defensive action. |
| unwanted_action | the action to take. |
| unwanted_param | user parameter to action. |
| tcp_mss | maximum segment size of tcp socket. |
| do_udp | if udp is done. |
| sslctx | context to create outgoing connections with (if enabled). |
| delayclose | if not 0, udp sockets are delayed before timeout closure. msec to wait on timeouted udp sockets. |
| dtenv | environment to send dnstap events with (if enabled). |
| void outside_network_delete | ( | struct outside_network * | outnet | ) |
Delete outside_network structure.
| outnet | object to delete. |
| void outside_network_quit_prepare | ( | struct outside_network * | outnet | ) |
Prepare for quit. Sends no more queries, even if queued up.
| outnet | object to prepare for removal |
| int pending_cmp | ( | const void * | key1, |
| const void * | key2 | ||
| ) |
compare function of pending rbtree
| void pending_delete | ( | struct outside_network * | outnet, |
| struct pending * | p | ||
| ) |
Delete pending answer.
| outnet | outside network the pending query is part of. Internal feature: if outnet is NULL, p is not unlinked from rbtree. |
| p | deleted |
| struct waiting_tcp* pending_tcp_query | ( | struct serviced_query * | sq, |
| struct sldns_buffer * | packet, | ||
| int | timeout, | ||
| comm_point_callback_type * | callback, | ||
| void * | callback_arg | ||
| ) |
Send TCP query. May wait for TCP buffer. Selects ID to be random, and checks id.
| sq | serviced query. |
| packet | wireformat query to send to destination. copied from. |
| timeout | in milliseconds from now. Timer starts running now. Timer may expire if all buffers are used, without any query been sent to the server yet. |
| callback | function to call on error, timeout or reply. |
| callback_arg | user argument for callback function. |
| struct pending* pending_udp_query | ( | struct serviced_query * | sq, |
| struct sldns_buffer * | packet, | ||
| int | timeout, | ||
| comm_point_callback_type * | callback, | ||
| void * | callback_arg | ||
| ) |
Send UDP query, create pending answer. Changes the ID for the query to be random and unique for that destination.
| sq | serviced query. |
| packet | wireformat query to send to destination. |
| timeout | in milliseconds from now. |
| callback | function to call on error, timeout or reply. |
| callback_arg | user argument for callback function. |
| void pending_udp_timer_cb | ( | void * | arg | ) |
callback for udp timeout
| void pending_udp_timer_delay_cb | ( | void * | arg | ) |
callback for udp delay for timeout
| int serviced_cmp | ( | const void * | key1, |
| const void * | key2 | ||
| ) |
compare function of serviced query rbtree
| size_t serviced_get_mem | ( | struct serviced_query * | sq | ) |
Get memory size in use by serviced query while it is servicing callbacks. This takes into account the pre-deleted status of it; it will be deleted when the callbacks are done.
| sq | serviced query. |
| int serviced_tcp_callback | ( | struct comm_point * | c, |
| void * | arg, | ||
| int | error, | ||
| struct comm_reply * | rep | ||
| ) |
TCP reply or error callback for serviced queries
| int serviced_udp_callback | ( | struct comm_point * | c, |
| void * | arg, | ||
| int | error, | ||
| struct comm_reply * | rep | ||
| ) |
callback for serviced query UDP answers