1 /*	$NetBSD: lwresd.h,v 1.4 2014/12/10 04:37:52 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 2000, 2001  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /* Id: lwresd.h,v 1.19 2007/06/19 23:46:59 tbox Exp  */
21 
22 #ifndef NAMED_LWRESD_H
23 #define NAMED_LWRESD_H 1
24 
25 /*! \file */
26 
27 #include <isc/types.h>
28 #include <isc/sockaddr.h>
29 
30 #include <isccfg/cfg.h>
31 
32 #include <dns/types.h>
33 
34 struct ns_lwresd {
35 	unsigned int magic;
36 
37 	isc_mutex_t lock;
38 	dns_view_t *view;
39 	ns_lwsearchlist_t *search;
40 	unsigned int ndots;
41 	isc_mem_t *mctx;
42 	isc_boolean_t shutting_down;
43 	unsigned int refs;
44 };
45 
46 struct ns_lwreslistener {
47 	unsigned int magic;
48 
49 	isc_mutex_t lock;
50 	isc_mem_t *mctx;
51 	isc_sockaddr_t address;
52 	ns_lwresd_t *manager;
53 	isc_socket_t *sock;
54 	unsigned int refs;
55 	ISC_LIST(ns_lwdclientmgr_t) cmgrs;
56 	ISC_LINK(ns_lwreslistener_t) link;
57 };
58 
59 /*%
60  * Configure lwresd.
61  */
62 isc_result_t
63 ns_lwresd_configure(isc_mem_t *mctx, const cfg_obj_t *config);
64 
65 isc_result_t
66 ns_lwresd_parseeresolvconf(isc_mem_t *mctx, cfg_parser_t *pctx,
67 			   cfg_obj_t **configp);
68 
69 /*%
70  * Trigger shutdown.
71  */
72 void
73 ns_lwresd_shutdown(void);
74 
75 /*
76  * Manager functions
77  */
78 /*% create manager */
79 isc_result_t
80 ns_lwdmanager_create(isc_mem_t *mctx, const cfg_obj_t *lwres,
81 		      ns_lwresd_t **lwresdp);
82 
83 /*% attach to manager */
84 void
85 ns_lwdmanager_attach(ns_lwresd_t *source, ns_lwresd_t **targetp);
86 
87 /*% detach from manager */
88 void
89 ns_lwdmanager_detach(ns_lwresd_t **lwresdp);
90 
91 /*
92  * Listener functions
93  */
94 /*% attach to listener */
95 void
96 ns_lwreslistener_attach(ns_lwreslistener_t *source,
97 			ns_lwreslistener_t **targetp);
98 
99 /*% detach from lister */
100 void
101 ns_lwreslistener_detach(ns_lwreslistener_t **listenerp);
102 
103 /*% link client manager */
104 void
105 ns_lwreslistener_unlinkcm(ns_lwreslistener_t *listener, ns_lwdclientmgr_t *cm);
106 
107 /*% unlink client manager */
108 void
109 ns_lwreslistener_linkcm(ns_lwreslistener_t *listener, ns_lwdclientmgr_t *cm);
110 
111 
112 
113 
114 /*
115  * INTERNAL FUNCTIONS.
116  */
117 void *
118 ns__lwresd_memalloc(void *arg, size_t size);
119 
120 void
121 ns__lwresd_memfree(void *arg, void *mem, size_t size);
122 
123 #endif /* NAMED_LWRESD_H */
124