cfg->do_tcp?cfg->outgoing_num_tcp:0,
worker->daemon->env->infra_cache, worker->rndstate,
cfg->use_caps_bits_for_id, worker->ports, worker->numports,
- cfg->unwanted_threshold, &worker_alloc_cleanup, worker);
+ cfg->unwanted_threshold, &worker_alloc_cleanup, worker,
+ cfg->do_udp);
if(!worker->back) {
log_err("could not create outgoing sockets");
worker_delete(worker);
29 October 2009: Wouter
- iana portlist updated.
- edns-buffer-size option, default 4096.
+ - fixed do-udp: no.
28 October 2009: Wouter
- removed abort on prealloc failure, error still printed but softfail.
cfg->do_tcp?cfg->outgoing_num_tcp:0,
w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id,
ports, numports, cfg->unwanted_threshold,
- &libworker_alloc_cleanup, w);
+ &libworker_alloc_cleanup, w, cfg->do_udp);
if(!w->is_bg || w->is_bg_thread) {
lock_basic_unlock(&ctx->cfglock);
}
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,
- void (*unwanted_action)(void*), void* unwanted_param)
+ void (*unwanted_action)(void*), void* unwanted_param, int do_udp)
{
struct outside_network* outnet = (struct outside_network*)
calloc(1, sizeof(struct outside_network));
outnet->unwanted_action = unwanted_action;
outnet->unwanted_param = unwanted_param;
outnet->use_caps_for_id = use_caps_for_id;
+ outnet->do_udp = do_udp;
if(numavailports == 0) {
log_err("no outgoing ports available");
outside_network_delete(outnet);
}
}
+static int
+serviced_tcp_send(struct serviced_query* sq, ldns_buffer* buff)
+{
+ int vs, rtt;
+ uint8_t edns_lame_known;
+ if(!infra_host(sq->outnet->infra, &sq->addr, sq->addrlen,
+ *sq->outnet->now_secs, &vs, &edns_lame_known, &rtt))
+ return 0;
+ if(vs != -1)
+ sq->status = serviced_query_TCP_EDNS;
+ else sq->status = serviced_query_TCP;
+ serviced_encode(sq, buff, sq->status == serviced_query_TCP_EDNS);
+ sq->pending = pending_tcp_query(sq->outnet, buff, &sq->addr,
+ sq->addrlen, TCP_AUTH_QUERY_TIMEOUT, serviced_tcp_callback,
+ sq);
+ return sq->pending != NULL;
+}
+
int
serviced_udp_callback(struct comm_point* c, void* arg, int error,
struct comm_reply* rep)
return NULL;
}
/* perform first network action */
- if(!serviced_udp_send(sq, buff)) {
- (void)rbtree_delete(outnet->serviced, sq);
- free(sq->qbuf);
- free(sq);
- free(cb);
- return NULL;
+ if(outnet->do_udp) {
+ if(!serviced_udp_send(sq, buff)) {
+ (void)rbtree_delete(outnet->serviced, sq);
+ free(sq->qbuf);
+ free(sq);
+ free(cb);
+ return NULL;
+ }
+ } else {
+ if(!serviced_tcp_send(sq, buff)) {
+ (void)rbtree_delete(outnet->serviced, sq);
+ free(sq->qbuf);
+ free(sq);
+ free(cb);
+ return NULL;
+ }
}
}
/* add callback to list of callbacks */
/** linked list of available commpoints, unused file descriptors,
* for use as outgoing UDP ports. cp.fd=-1 in them. */
struct port_comm* unused_fds;
+ /** if udp is done */
+ int do_udp;
/** array of outgoing IP4 interfaces */
struct port_if* ip4_ifs;
* @param unwanted_threshold: when to take defensive action.
* @param unwanted_action: the action to take.
* @param unwanted_param: user parameter to action.
+ * @param do_udp: if udp is done.
* @return: the new structure (with no pending answers) or NULL on error.
*/
struct outside_network* outside_network_create(struct comm_base* base,
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,
- void (*unwanted_action)(void*), void* unwanted_param);
+ void (*unwanted_action)(void*), void* unwanted_param, int do_udp);
/**
* Delete outside_network structure.
struct ub_randstate* ATTR_UNUSED(rnd),
int ATTR_UNUSED(use_caps_for_id), int* ATTR_UNUSED(availports),
int ATTR_UNUSED(numavailports), size_t ATTR_UNUSED(unwanted_threshold),
- void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param))
+ void (*unwanted_action)(void*), void* ATTR_UNUSED(unwanted_param),
+ int ATTR_UNUSED(do_udp))
{
struct outside_network* outnet = calloc(1,
sizeof(struct outside_network));