xref: /netbsd-src/external/bsd/libbind/dist/include/isc/ctl.h (revision 5bbd2a12505d72a8177929a37b5cee489d0a1cfd)
1*5bbd2a12Schristos /*	$NetBSD: ctl.h,v 1.1.1.2 2012/09/09 16:07:49 christos Exp $	*/
2b5677b36Schristos 
3b5677b36Schristos #ifndef ISC_CTL_H
4b5677b36Schristos #define ISC_CTL_H
5b5677b36Schristos 
6b5677b36Schristos /*
7b5677b36Schristos  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
8b5677b36Schristos  * Copyright (c) 1998,1999 by Internet Software Consortium.
9b5677b36Schristos  *
10b5677b36Schristos  * Permission to use, copy, modify, and distribute this software for any
11b5677b36Schristos  * purpose with or without fee is hereby granted, provided that the above
12b5677b36Schristos  * copyright notice and this permission notice appear in all copies.
13b5677b36Schristos  *
14b5677b36Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15b5677b36Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16b5677b36Schristos  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
17b5677b36Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18b5677b36Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19b5677b36Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20b5677b36Schristos  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21b5677b36Schristos  */
22b5677b36Schristos 
23b5677b36Schristos /*
24b5677b36Schristos  * Id: ctl.h,v 1.5 2005/04/27 04:56:17 sra Exp
25b5677b36Schristos  */
26b5677b36Schristos 
27b5677b36Schristos /*! \file */
28b5677b36Schristos 
29b5677b36Schristos #include <sys/types.h>
30b5677b36Schristos #include <sys/socket.h>
31b5677b36Schristos 
32b5677b36Schristos #include <isc/eventlib.h>
33b5677b36Schristos 
34b5677b36Schristos /* Macros. */
35b5677b36Schristos 
36b5677b36Schristos #define	CTL_MORE	0x0001	/*%< More will be / should be sent. */
37b5677b36Schristos #define	CTL_EXIT	0x0002	/*%< Close connection after this. */
38b5677b36Schristos #define	CTL_DATA	0x0004	/*%< Go into / this is DATA mode. */
39b5677b36Schristos /* Types. */
40b5677b36Schristos 
41b5677b36Schristos struct ctl_cctx;
42b5677b36Schristos struct ctl_sctx;
43b5677b36Schristos struct ctl_sess;
44b5677b36Schristos struct ctl_verb;
45b5677b36Schristos 
46b5677b36Schristos enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
47b5677b36Schristos 
48b5677b36Schristos typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
49b5677b36Schristos 
50b5677b36Schristos typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
51b5677b36Schristos 			     const struct ctl_verb *, const char *,
52b5677b36Schristos 			     u_int, const void *, void *);
53b5677b36Schristos 
54b5677b36Schristos typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
55b5677b36Schristos 
56b5677b36Schristos typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int);
57b5677b36Schristos 
58b5677b36Schristos struct ctl_verb {
59b5677b36Schristos 	const char *	name;
60b5677b36Schristos 	ctl_verbfunc	func;
61b5677b36Schristos 	const char *	help;
62b5677b36Schristos };
63b5677b36Schristos 
64b5677b36Schristos /* General symbols. */
65b5677b36Schristos 
66b5677b36Schristos #define	ctl_logger	__ctl_logger
67b5677b36Schristos 
68b5677b36Schristos #ifdef __GNUC__
69b5677b36Schristos void			ctl_logger(enum ctl_severity, const char *, ...)
70b5677b36Schristos 				__attribute__((__format__(__printf__, 2, 3)));
71b5677b36Schristos #else
72b5677b36Schristos void			ctl_logger(enum ctl_severity, const char *, ...);
73b5677b36Schristos #endif
74b5677b36Schristos 
75b5677b36Schristos /* Client symbols. */
76b5677b36Schristos 
77b5677b36Schristos #define	ctl_client	__ctl_client
78b5677b36Schristos #define	ctl_endclient	__ctl_endclient
79b5677b36Schristos #define	ctl_command	__ctl_command
80b5677b36Schristos 
81b5677b36Schristos struct ctl_cctx *	ctl_client(evContext, const struct sockaddr *, size_t,
82b5677b36Schristos 				   const struct sockaddr *, size_t,
83b5677b36Schristos 				   ctl_clntdone, void *,
84b5677b36Schristos 				   u_int, ctl_logfunc);
85b5677b36Schristos void			ctl_endclient(struct ctl_cctx *);
86b5677b36Schristos int			ctl_command(struct ctl_cctx *, const char *, size_t,
87b5677b36Schristos 				    ctl_clntdone, void *);
88b5677b36Schristos 
89b5677b36Schristos /* Server symbols. */
90b5677b36Schristos 
91b5677b36Schristos #define	ctl_server	__ctl_server
92b5677b36Schristos #define	ctl_endserver	__ctl_endserver
93b5677b36Schristos #define	ctl_response	__ctl_response
94b5677b36Schristos #define	ctl_sendhelp	__ctl_sendhelp
95b5677b36Schristos #define ctl_getcsctx	__ctl_getcsctx
96b5677b36Schristos #define ctl_setcsctx	__ctl_setcsctx
97b5677b36Schristos 
98b5677b36Schristos struct ctl_sctx *	ctl_server(evContext, const struct sockaddr *, size_t,
99b5677b36Schristos 				   const struct ctl_verb *,
100b5677b36Schristos 				   u_int, u_int,
101b5677b36Schristos 				   u_int, int, int,
102b5677b36Schristos 				   ctl_logfunc, void *);
103b5677b36Schristos void			ctl_endserver(struct ctl_sctx *);
104b5677b36Schristos void			ctl_response(struct ctl_sess *, u_int,
105b5677b36Schristos 				     const char *, u_int, const void *,
106b5677b36Schristos 				     ctl_srvrdone, void *,
107b5677b36Schristos 				     const char *, size_t);
108b5677b36Schristos void			ctl_sendhelp(struct ctl_sess *, u_int);
109b5677b36Schristos void *			ctl_getcsctx(struct ctl_sess *);
110b5677b36Schristos void *			ctl_setcsctx(struct ctl_sess *, void *);
111b5677b36Schristos 
112b5677b36Schristos #endif /*ISC_CTL_H*/
113b5677b36Schristos 
114b5677b36Schristos /*! \file */
115