1255579Sdes/* 2255579Sdes * libunbound/worker.h - prototypes for worker methods. 3255579Sdes * 4255579Sdes * Copyright (c) 2007, NLnet Labs. All rights reserved. 5255579Sdes * 6255579Sdes * This software is open source. 7255579Sdes * 8255579Sdes * Redistribution and use in source and binary forms, with or without 9255579Sdes * modification, are permitted provided that the following conditions 10255579Sdes * are met: 11255579Sdes * 12255579Sdes * Redistributions of source code must retain the above copyright notice, 13255579Sdes * this list of conditions and the following disclaimer. 14255579Sdes * 15255579Sdes * Redistributions in binary form must reproduce the above copyright notice, 16255579Sdes * this list of conditions and the following disclaimer in the documentation 17255579Sdes * and/or other materials provided with the distribution. 18255579Sdes * 19255579Sdes * Neither the name of the NLNET LABS nor the names of its contributors may 20255579Sdes * be used to endorse or promote products derived from this software without 21255579Sdes * specific prior written permission. 22255579Sdes * 23255579Sdes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24255579Sdes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25255579Sdes * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26255579Sdes * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 27255579Sdes * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28255579Sdes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29255579Sdes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30255579Sdes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31255579Sdes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32255579Sdes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33255579Sdes * POSSIBILITY OF SUCH DAMAGE. 34255579Sdes */ 35255579Sdes 36255579Sdes/** 37255579Sdes * \file 38255579Sdes * 39255579Sdes * This file declares the methods any worker has to implement. 40255579Sdes */ 41255579Sdes 42255579Sdes#ifndef LIBUNBOUND_WORKER_H 43255579Sdes#define LIBUNBOUND_WORKER_H 44255579Sdes 45287917Sdes#include "sldns/sbuffer.h" 46255588Sdes#include "util/data/packed_rrset.h" /* for enum sec_status */ 47255583Sdesstruct comm_reply; 48255583Sdesstruct comm_point; 49255583Sdesstruct module_qstate; 50255583Sdesstruct tube; 51255583Sdes 52255579Sdes/** 53255583Sdes * Worker service routine to send serviced queries to authoritative servers. 54255583Sdes * @param qname: query name. (host order) 55255583Sdes * @param qnamelen: length in bytes of qname, including trailing 0. 56255583Sdes * @param qtype: query type. (host order) 57255583Sdes * @param qclass: query class. (host order) 58255583Sdes * @param flags: host order flags word, with opcode and CD bit. 59255583Sdes * @param dnssec: if set, EDNS record will have DO bit set. 60255583Sdes * @param want_dnssec: signatures needed. 61276605Sdes * @param nocaps: ignore capsforid(if in config), do not perturb qname. 62255583Sdes * @param addr: where to. 63255583Sdes * @param addrlen: length of addr. 64255583Sdes * @param zone: delegation point name. 65255583Sdes * @param zonelen: length of zone name wireformat dname. 66255583Sdes * @param q: wich query state to reactivate upon return. 67255583Sdes * @return: false on failure (memory or socket related). no query was 68255583Sdes * sent. 69255583Sdes */ 70255583Sdesstruct outbound_entry* libworker_send_query(uint8_t* qname, size_t qnamelen, 71255583Sdes uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, 72276605Sdes int want_dnssec, int nocaps, struct sockaddr_storage* addr, 73276605Sdes socklen_t addrlen, uint8_t* zone, size_t zonelen, 74276605Sdes struct module_qstate* q); 75255583Sdes 76255583Sdes/** process incoming replies from the network */ 77255583Sdesint libworker_handle_reply(struct comm_point* c, void* arg, int error, 78255583Sdes struct comm_reply* reply_info); 79255583Sdes 80255583Sdes/** process incoming serviced query replies from the network */ 81255583Sdesint libworker_handle_service_reply(struct comm_point* c, void* arg, int error, 82255583Sdes struct comm_reply* reply_info); 83255583Sdes 84255583Sdes/** handle control command coming into server */ 85255583Sdesvoid libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, 86255583Sdes int err, void* arg); 87255583Sdes 88255583Sdes/** mesh callback with fg results */ 89266114Sdesvoid libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, 90255583Sdes enum sec_status s, char* why_bogus); 91255583Sdes 92255583Sdes/** mesh callback with bg results */ 93266114Sdesvoid libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, 94255583Sdes enum sec_status s, char* why_bogus); 95255583Sdes 96266777Sdes/** mesh callback with event results */ 97266777Sdesvoid libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf, 98266777Sdes enum sec_status s, char* why_bogus); 99266777Sdes 100255583Sdes/** 101255579Sdes * Worker signal handler function. User argument is the worker itself. 102255579Sdes * @param sig: signal number. 103255579Sdes * @param arg: the worker (main worker) that handles signals. 104255579Sdes */ 105255579Sdesvoid worker_sighandler(int sig, void* arg); 106255579Sdes 107255579Sdes/** 108255579Sdes * Worker service routine to send serviced queries to authoritative servers. 109255579Sdes * @param qname: query name. (host order) 110255579Sdes * @param qnamelen: length in bytes of qname, including trailing 0. 111255579Sdes * @param qtype: query type. (host order) 112255579Sdes * @param qclass: query class. (host order) 113255579Sdes * @param flags: host order flags word, with opcode and CD bit. 114255579Sdes * @param dnssec: if set, EDNS record will have DO bit set. 115255579Sdes * @param want_dnssec: signatures needed. 116276605Sdes * @param nocaps: ignore capsforid(if in config), do not perturb qname. 117255579Sdes * @param addr: where to. 118255579Sdes * @param addrlen: length of addr. 119255579Sdes * @param zone: wireformat dname of the zone. 120255579Sdes * @param zonelen: length of zone name. 121255579Sdes * @param q: wich query state to reactivate upon return. 122255579Sdes * @return: false on failure (memory or socket related). no query was 123255579Sdes * sent. 124255579Sdes */ 125255579Sdesstruct outbound_entry* worker_send_query(uint8_t* qname, size_t qnamelen, 126255579Sdes uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, 127276605Sdes int want_dnssec, int nocaps, struct sockaddr_storage* addr, 128276605Sdes socklen_t addrlen, uint8_t* zone, size_t zonelen, 129276605Sdes struct module_qstate* q); 130255579Sdes 131255579Sdes/** 132255579Sdes * process control messages from the main thread. Frees the control 133255579Sdes * command message. 134255579Sdes * @param tube: tube control message came on. 135255579Sdes * @param msg: message contents. Is freed. 136255579Sdes * @param len: length of message. 137255579Sdes * @param error: if error (NETEVENT_*) happened. 138255579Sdes * @param arg: user argument 139255579Sdes */ 140255579Sdesvoid worker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, 141255579Sdes int error, void* arg); 142255579Sdes 143255579Sdes/** handles callbacks from listening event interface */ 144255579Sdesint worker_handle_request(struct comm_point* c, void* arg, int error, 145255579Sdes struct comm_reply* repinfo); 146255579Sdes 147255579Sdes/** process incoming replies from the network */ 148255579Sdesint worker_handle_reply(struct comm_point* c, void* arg, int error, 149255579Sdes struct comm_reply* reply_info); 150255579Sdes 151255579Sdes/** process incoming serviced query replies from the network */ 152255579Sdesint worker_handle_service_reply(struct comm_point* c, void* arg, int error, 153255579Sdes struct comm_reply* reply_info); 154255579Sdes 155255579Sdes/** cleanup the cache to remove all rrset IDs from it, arg is worker */ 156255579Sdesvoid worker_alloc_cleanup(void* arg); 157255579Sdes 158255579Sdes/** statistics timer callback handler */ 159255579Sdesvoid worker_stat_timer_cb(void* arg); 160255579Sdes 161255579Sdes/** probe timer callback handler */ 162255579Sdesvoid worker_probe_timer_cb(void* arg); 163255579Sdes 164255579Sdes/** start accept callback handler */ 165255579Sdesvoid worker_start_accept(void* arg); 166255579Sdes 167255579Sdes/** stop accept callback handler */ 168255579Sdesvoid worker_stop_accept(void* arg); 169255579Sdes 170255579Sdes/** handle remote control accept callbacks */ 171255579Sdesint remote_accept_callback(struct comm_point*, void*, int, struct comm_reply*); 172255579Sdes 173255579Sdes/** handle remote control data callbacks */ 174255579Sdesint remote_control_callback(struct comm_point*, void*, int, struct comm_reply*); 175255579Sdes 176255579Sdes/** routine to printout option values over SSL */ 177255579Sdesvoid remote_get_opt_ssl(char* line, void* arg); 178255579Sdes 179255579Sdes#endif /* LIBUNBOUND_WORKER_H */ 180