xref: /netbsd/external/bsd/libbind/dist/include/isc/ctl.h (revision 6550d01e)
1 /*	$NetBSD: ctl.h,v 1.1.1.1 2009/04/12 15:33:34 christos Exp $	*/
2 
3 #ifndef ISC_CTL_H
4 #define ISC_CTL_H
5 
6 /*
7  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
8  * Copyright (c) 1998,1999 by Internet Software Consortium.
9  *
10  * Permission to use, copy, modify, and distribute this software for any
11  * purpose with or without fee is hereby granted, provided that the above
12  * copyright notice and this permission notice appear in all copies.
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 
23 /*
24  * Id: ctl.h,v 1.5 2005/04/27 04:56:17 sra Exp
25  */
26 
27 /*! \file */
28 
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 
32 #include <isc/eventlib.h>
33 
34 /* Macros. */
35 
36 #define	CTL_MORE	0x0001	/*%< More will be / should be sent. */
37 #define	CTL_EXIT	0x0002	/*%< Close connection after this. */
38 #define	CTL_DATA	0x0004	/*%< Go into / this is DATA mode. */
39 /* Types. */
40 
41 struct ctl_cctx;
42 struct ctl_sctx;
43 struct ctl_sess;
44 struct ctl_verb;
45 
46 enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
47 
48 typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
49 
50 typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
51 			     const struct ctl_verb *, const char *,
52 			     u_int, const void *, void *);
53 
54 typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
55 
56 typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int);
57 
58 struct ctl_verb {
59 	const char *	name;
60 	ctl_verbfunc	func;
61 	const char *	help;
62 };
63 
64 /* General symbols. */
65 
66 #define	ctl_logger	__ctl_logger
67 
68 #ifdef __GNUC__
69 void			ctl_logger(enum ctl_severity, const char *, ...)
70 				__attribute__((__format__(__printf__, 2, 3)));
71 #else
72 void			ctl_logger(enum ctl_severity, const char *, ...);
73 #endif
74 
75 /* Client symbols. */
76 
77 #define	ctl_client	__ctl_client
78 #define	ctl_endclient	__ctl_endclient
79 #define	ctl_command	__ctl_command
80 
81 struct ctl_cctx *	ctl_client(evContext, const struct sockaddr *, size_t,
82 				   const struct sockaddr *, size_t,
83 				   ctl_clntdone, void *,
84 				   u_int, ctl_logfunc);
85 void			ctl_endclient(struct ctl_cctx *);
86 int			ctl_command(struct ctl_cctx *, const char *, size_t,
87 				    ctl_clntdone, void *);
88 
89 /* Server symbols. */
90 
91 #define	ctl_server	__ctl_server
92 #define	ctl_endserver	__ctl_endserver
93 #define	ctl_response	__ctl_response
94 #define	ctl_sendhelp	__ctl_sendhelp
95 #define ctl_getcsctx	__ctl_getcsctx
96 #define ctl_setcsctx	__ctl_setcsctx
97 
98 struct ctl_sctx *	ctl_server(evContext, const struct sockaddr *, size_t,
99 				   const struct ctl_verb *,
100 				   u_int, u_int,
101 				   u_int, int, int,
102 				   ctl_logfunc, void *);
103 void			ctl_endserver(struct ctl_sctx *);
104 void			ctl_response(struct ctl_sess *, u_int,
105 				     const char *, u_int, const void *,
106 				     ctl_srvrdone, void *,
107 				     const char *, size_t);
108 void			ctl_sendhelp(struct ctl_sess *, u_int);
109 void *			ctl_getcsctx(struct ctl_sess *);
110 void *			ctl_setcsctx(struct ctl_sess *, void *);
111 
112 #endif /*ISC_CTL_H*/
113 
114 /*! \file */
115