worker.h revision 266114
156160Sru/* 2114472Sru * libunbound/worker.h - prototypes for worker methods. 356160Sru * 4114472Sru * Copyright (c) 2007, NLnet Labs. All rights reserved. 5114472Sru * 656160Sru * This software is open source. 756160Sru * 856160Sru * Redistribution and use in source and binary forms, with or without 956160Sru * modification, are permitted provided that the following conditions 1056160Sru * are met: 1156160Sru * 1256160Sru * Redistributions of source code must retain the above copyright notice, 1356160Sru * this list of conditions and the following disclaimer. 1456160Sru * 1556160Sru * Redistributions in binary form must reproduce the above copyright notice, 1656160Sru * this list of conditions and the following disclaimer in the documentation 1756160Sru * and/or other materials provided with the distribution. 1856160Sru * 1956160Sru * Neither the name of the NLNET LABS nor the names of its contributors may 2056160Sru * be used to endorse or promote products derived from this software without 2156160Sru * specific prior written permission. 2256160Sru * 2356160Sru * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2456160Sru * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2556160Sru * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2656160Sru * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 2793139Sru * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2856160Sru * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2956160Sru * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3056160Sru * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3193139Sru * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32100513Sru * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33100513Sru * POSSIBILITY OF SUCH DAMAGE. 34100513Sru */ 35100513Sru 36100513Sru/** 37100513Sru * \file 38114472Sru * 39114472Sru * This file declares the methods any worker has to implement. 40100513Sru */ 41100513Sru 42100513Sru#ifndef LIBUNBOUND_WORKER_H 4356160Sru#define LIBUNBOUND_WORKER_H 4456160Sru 4556160Sru#include "ldns/sbuffer.h" 4656160Sru#include "util/data/packed_rrset.h" /* for enum sec_status */ 4756160Srustruct comm_reply; 4856160Srustruct comm_point; 4956160Srustruct module_qstate; 5056160Srustruct tube; 51100513Sru 52100513Sru/** 53100513Sru * Worker service routine to send serviced queries to authoritative servers. 5456160Sru * @param qname: query name. (host order) 5556160Sru * @param qnamelen: length in bytes of qname, including trailing 0. 5656160Sru * @param qtype: query type. (host order) 5756160Sru * @param qclass: query class. (host order) 58100513Sru * @param flags: host order flags word, with opcode and CD bit. 59100513Sru * @param dnssec: if set, EDNS record will have DO bit set. 6056160Sru * @param want_dnssec: signatures needed. 6156160Sru * @param addr: where to. 6256160Sru * @param addrlen: length of addr. 6356160Sru * @param zone: delegation point name. 6456160Sru * @param zonelen: length of zone name wireformat dname. 6556160Sru * @param q: wich query state to reactivate upon return. 66100513Sru * @return: false on failure (memory or socket related). no query was 67100513Sru * sent. 6856160Sru */ 6956160Srustruct outbound_entry* libworker_send_query(uint8_t* qname, size_t qnamelen, 7056160Sru uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, 7156160Sru int want_dnssec, struct sockaddr_storage* addr, socklen_t addrlen, 7256160Sru uint8_t* zone, size_t zonelen, struct module_qstate* q); 7356160Sru 7456160Sru/** process incoming replies from the network */ 7556160Sruint libworker_handle_reply(struct comm_point* c, void* arg, int error, 7656160Sru struct comm_reply* reply_info); 7756160Sru 7856160Sru/** process incoming serviced query replies from the network */ 7956160Sruint libworker_handle_service_reply(struct comm_point* c, void* arg, int error, 8056160Sru struct comm_reply* reply_info); 8156160Sru 8256160Sru/** handle control command coming into server */ 8356160Sruvoid libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, 8456160Sru int err, void* arg); 8556160Sru 8656160Sru/** mesh callback with fg results */ 8756160Sruvoid libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, 8856160Sru enum sec_status s, char* why_bogus); 8956160Sru 9056160Sru/** mesh callback with bg results */ 9156160Sruvoid libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, 9256160Sru enum sec_status s, char* why_bogus); 9356160Sru 9456160Sru/** 9556160Sru * Worker signal handler function. User argument is the worker itself. 9656160Sru * @param sig: signal number. 9756160Sru * @param arg: the worker (main worker) that handles signals. 9856160Sru */ 9956160Sruvoid worker_sighandler(int sig, void* arg); 10056160Sru 10156160Sru/** 102100513Sru * Worker service routine to send serviced queries to authoritative servers. 10356160Sru * @param qname: query name. (host order) 104114472Sru * @param qnamelen: length in bytes of qname, including trailing 0. 105100513Sru * @param qtype: query type. (host order) 10656160Sru * @param qclass: query class. (host order) 10756160Sru * @param flags: host order flags word, with opcode and CD bit. 108114472Sru * @param dnssec: if set, EDNS record will have DO bit set. 10956160Sru * @param want_dnssec: signatures needed. 11056160Sru * @param addr: where to. 11156160Sru * @param addrlen: length of addr. 11256160Sru * @param zone: wireformat dname of the zone. 113114472Sru * @param zonelen: length of zone name. 114114472Sru * @param q: wich query state to reactivate upon return. 11556160Sru * @return: false on failure (memory or socket related). no query was 11656160Sru * sent. 11756160Sru */ 11856160Srustruct outbound_entry* worker_send_query(uint8_t* qname, size_t qnamelen, 11956160Sru uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, 12056160Sru int want_dnssec, struct sockaddr_storage* addr, socklen_t addrlen, 12156160Sru uint8_t* zone, size_t zonelen, struct module_qstate* q); 12256160Sru 12356160Sru/** 12456160Sru * process control messages from the main thread. Frees the control 12556160Sru * command message. 12656160Sru * @param tube: tube control message came on. 12756160Sru * @param msg: message contents. Is freed. 12856160Sru * @param len: length of message. 12956160Sru * @param error: if error (NETEVENT_*) happened. 13056160Sru * @param arg: user argument 13156160Sru */ 13256160Sruvoid worker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, 13356160Sru int error, void* arg); 13456160Sru 13556160Sru/** handles callbacks from listening event interface */ 13656160Sruint worker_handle_request(struct comm_point* c, void* arg, int error, 13756160Sru struct comm_reply* repinfo); 13856160Sru 13956160Sru/** process incoming replies from the network */ 14056160Sruint worker_handle_reply(struct comm_point* c, void* arg, int error, 14156160Sru struct comm_reply* reply_info); 14256160Sru 14356160Sru/** process incoming serviced query replies from the network */ 14456160Sruint worker_handle_service_reply(struct comm_point* c, void* arg, int error, 14556160Sru struct comm_reply* reply_info); 14656160Sru 14756160Sru/** cleanup the cache to remove all rrset IDs from it, arg is worker */ 14856160Sruvoid worker_alloc_cleanup(void* arg); 14956160Sru 15056160Sru/** statistics timer callback handler */ 15156160Sruvoid worker_stat_timer_cb(void* arg); 15256160Sru 15356160Sru/** probe timer callback handler */ 15456160Sruvoid worker_probe_timer_cb(void* arg); 15556160Sru 15656160Sru/** start accept callback handler */ 15756160Sruvoid worker_start_accept(void* arg); 15856160Sru 15956160Sru/** stop accept callback handler */ 16056160Sruvoid worker_stop_accept(void* arg); 16156160Sru 16256160Sru/** handle remote control accept callbacks */ 16356160Sruint remote_accept_callback(struct comm_point*, void*, int, struct comm_reply*); 16456160Sru 16556160Sru/** handle remote control data callbacks */ 16656160Sruint remote_control_callback(struct comm_point*, void*, int, struct comm_reply*); 16756160Sru 16856160Sru/** routine to printout option values over SSL */ 16956160Sruvoid remote_get_opt_ssl(char* line, void* arg); 17056160Sru 17156160Sru#endif /* LIBUNBOUND_WORKER_H */ 17256160Sru