Home | History | Annotate | Line # | Download | only in omapip
      1 /*	$NetBSD: isclib.h,v 1.5 2022/04/03 01:10:59 christos Exp $	*/
      2 
      3 /* isclib.h
      4 
      5    connections to the isc and dns libraries */
      6 
      7 /*
      8  * Copyright (C) 2009-2022 Internet Systems Consortium, Inc. ("ISC")
      9  *
     10  * This Source Code Form is subject to the terms of the Mozilla Public
     11  * License, v. 2.0. If a copy of the MPL was not distributed with this
     12  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     13  *
     14  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
     15  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     16  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
     17  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     19  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
     20  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     21  *
     22  *   Internet Systems Consortium, Inc.
     23  *   PO Box 360
     24  *   Newmarket, NH 03857 USA
     25  *   <info (at) isc.org>
     26  *   http://www.isc.org/
     27  *
     28  */
     29 
     30 #ifndef ISCLIB_H
     31 #define ISCLIB_H
     32 
     33 #include "config.h"
     34 
     35 #include <syslog.h>
     36 
     37 #define MAXWIRE 256
     38 
     39 #include <sys/types.h>
     40 #include <sys/socket.h>
     41 
     42 #include <netinet/in.h>
     43 
     44 #include <arpa/inet.h>
     45 
     46 #include <unistd.h>
     47 #include <ctype.h>
     48 #include <stdio.h>
     49 #include <stdlib.h>
     50 #include <string.h>
     51 #include <netdb.h>
     52 
     53 #include <isc/buffer.h>
     54 #include <isc/lex.h>
     55 #include <isc/lib.h>
     56 #include <isc/app.h>
     57 #include <isc/managers.h>
     58 #include <isc/mem.h>
     59 #include <isc/parseint.h>
     60 #include <isc/socket.h>
     61 #include <isc/sockaddr.h>
     62 #include <isc/task.h>
     63 #include <isc/timer.h>
     64 #include <isc/heap.h>
     65 #include <isc/random.h>
     66 
     67 #include <irs/resconf.h>
     68 
     69 #include <dns/client.h>
     70 #include <dns/fixedname.h>
     71 #include <dns/keyvalues.h>
     72 #include <dns/lib.h>
     73 #include <dns/name.h>
     74 #include <dns/rdata.h>
     75 #include <dns/rdataclass.h>
     76 #include <dns/rdatalist.h>
     77 #include <dns/rdataset.h>
     78 #include <dns/rdatastruct.h>
     79 #include <dns/rdatatype.h>
     80 #include <dns/result.h>
     81 #include <dns/secalg.h>
     82 #include <dns/tsec.h>
     83 
     84 #include <dst/dst.h>
     85 
     86 #include "result.h"
     87 
     88 
     89 /*
     90  * DHCP context structure
     91  * This holds the libisc information for a dhcp entity
     92  */
     93 
     94 typedef struct dhcp_context {
     95 	isc_mem_t	*mctx;
     96 	isc_appctx_t	*actx;
     97 	int              actx_started; // ISC_TRUE if ctxstart has been called
     98 	int              actx_running; // ISC_TRUE if ctxrun has been called
     99 	isc_taskmgr_t	*taskmgr;
    100 	isc_nm_t	*netmgr;
    101 	isc_task_t	*task;
    102 	isc_socketmgr_t *socketmgr;
    103 	isc_timermgr_t	*timermgr;
    104 #if defined (NSUPDATE)
    105   	dns_client_t    *dnsclient;
    106 	int use_local4;
    107 	isc_sockaddr_t local4_sockaddr;
    108 	int use_local6;
    109 	isc_sockaddr_t local6_sockaddr;
    110 #endif
    111 } dhcp_context_t;
    112 
    113 extern dhcp_context_t dhcp_gbl_ctx;
    114 
    115 #define DHCP_MAXDNS_WIRE 256
    116 #define DHCP_MAXNS         3
    117 #define DHCP_HMAC_MD5_NAME "HMAC-MD5.SIG-ALG.REG.INT."
    118 #define DHCP_HMAC_SHA1_NAME "HMAC-SHA1.SIG-ALG.REG.INT."
    119 #define DHCP_HMAC_SHA224_NAME "HMAC-SHA224.SIG-ALG.REG.INT."
    120 #define DHCP_HMAC_SHA256_NAME "HMAC-SHA256.SIG-ALG.REG.INT."
    121 #define DHCP_HMAC_SHA384_NAME "HMAC-SHA384.SIG-ALG.REG.INT."
    122 #define DHCP_HMAC_SHA512_NAME "HMAC-SHA512.SIG-ALG.REG.INT."
    123 
    124 isc_result_t dhcp_isc_name(unsigned char    *namestr,
    125 			   dns_fixedname_t  *namefix,
    126 			   dns_name_t      **name);
    127 
    128 isc_result_t
    129 isclib_make_dst_key(char          *inname,
    130 		    char          *algorithm,
    131 		    unsigned char *secret,
    132 		    int            length,
    133 		    dst_key_t    **dstkey);
    134 
    135 #define DHCP_CONTEXT_PRE_DB  1
    136 #define DHCP_CONTEXT_POST_DB 2
    137 #define DHCP_DNS_CLIENT_LAZY_INIT 4
    138 isc_result_t dhcp_context_create(int              flags,
    139 				 struct in_addr  *local4,
    140 				 struct in6_addr *local6);
    141 void isclib_cleanup(void);
    142 
    143 void dhcp_signal_handler(int signal);
    144 extern int shutdown_signal;
    145 
    146 #if defined (NSUPDATE)
    147 isc_result_t dns_client_init(void);
    148 #endif /* defined NSUPDATE */
    149 
    150 #endif /* ISCLIB_H */
    151