xref: /titanic_41/usr/src/lib/libresolv2/include/isc/ctl.h (revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829)
17c478bd9Sstevel@tonic-gate #ifndef ISC_CTL_H
27c478bd9Sstevel@tonic-gate #define ISC_CTL_H
37c478bd9Sstevel@tonic-gate 
47c478bd9Sstevel@tonic-gate /*
5*9525b14bSRao Shoaib  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
67c478bd9Sstevel@tonic-gate  * Copyright (c) 1998,1999 by Internet Software Consortium.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
97c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
107c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
117c478bd9Sstevel@tonic-gate  *
12*9525b14bSRao Shoaib  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
13*9525b14bSRao Shoaib  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14*9525b14bSRao Shoaib  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
15*9525b14bSRao Shoaib  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16*9525b14bSRao Shoaib  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17*9525b14bSRao Shoaib  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
18*9525b14bSRao Shoaib  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
197c478bd9Sstevel@tonic-gate  */
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate /*
22*9525b14bSRao Shoaib  * $Id: ctl.h,v 1.5 2005/04/27 04:56:17 sra Exp $
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
25*9525b14bSRao Shoaib /*! \file */
26*9525b14bSRao Shoaib 
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/socket.h>
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <isc/eventlib.h>
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /* Macros. */
337c478bd9Sstevel@tonic-gate 
34*9525b14bSRao Shoaib #define	CTL_MORE	0x0001	/*%< More will be / should be sent. */
35*9525b14bSRao Shoaib #define	CTL_EXIT	0x0002	/*%< Close connection after this. */
36*9525b14bSRao Shoaib #define	CTL_DATA	0x0004	/*%< Go into / this is DATA mode. */
377c478bd9Sstevel@tonic-gate /* Types. */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate struct ctl_cctx;
407c478bd9Sstevel@tonic-gate struct ctl_sctx;
417c478bd9Sstevel@tonic-gate struct ctl_sess;
427c478bd9Sstevel@tonic-gate struct ctl_verb;
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
457c478bd9Sstevel@tonic-gate 
46*9525b14bSRao Shoaib typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
49*9525b14bSRao Shoaib 			     const struct ctl_verb *, const char *,
50*9525b14bSRao Shoaib 			     u_int, const void *, void *);
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int);
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate struct ctl_verb {
577c478bd9Sstevel@tonic-gate 	const char *	name;
587c478bd9Sstevel@tonic-gate 	ctl_verbfunc	func;
597c478bd9Sstevel@tonic-gate 	const char *	help;
607c478bd9Sstevel@tonic-gate };
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /* General symbols. */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #define	ctl_logger	__ctl_logger
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #ifdef __GNUC__
677c478bd9Sstevel@tonic-gate void			ctl_logger(enum ctl_severity, const char *, ...)
687c478bd9Sstevel@tonic-gate 				__attribute__((__format__(__printf__, 2, 3)));
697c478bd9Sstevel@tonic-gate #else
707c478bd9Sstevel@tonic-gate void			ctl_logger(enum ctl_severity, const char *, ...);
717c478bd9Sstevel@tonic-gate #endif
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /* Client symbols. */
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	ctl_client	__ctl_client
767c478bd9Sstevel@tonic-gate #define	ctl_endclient	__ctl_endclient
777c478bd9Sstevel@tonic-gate #define	ctl_command	__ctl_command
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate struct ctl_cctx *	ctl_client(evContext, const struct sockaddr *, size_t,
807c478bd9Sstevel@tonic-gate 				   const struct sockaddr *, size_t,
817c478bd9Sstevel@tonic-gate 				   ctl_clntdone, void *,
827c478bd9Sstevel@tonic-gate 				   u_int, ctl_logfunc);
837c478bd9Sstevel@tonic-gate void			ctl_endclient(struct ctl_cctx *);
847c478bd9Sstevel@tonic-gate int			ctl_command(struct ctl_cctx *, const char *, size_t,
857c478bd9Sstevel@tonic-gate 				    ctl_clntdone, void *);
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /* Server symbols. */
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #define	ctl_server	__ctl_server
907c478bd9Sstevel@tonic-gate #define	ctl_endserver	__ctl_endserver
917c478bd9Sstevel@tonic-gate #define	ctl_response	__ctl_response
927c478bd9Sstevel@tonic-gate #define	ctl_sendhelp	__ctl_sendhelp
937c478bd9Sstevel@tonic-gate #define ctl_getcsctx	__ctl_getcsctx
947c478bd9Sstevel@tonic-gate #define ctl_setcsctx	__ctl_setcsctx
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate struct ctl_sctx *	ctl_server(evContext, const struct sockaddr *, size_t,
977c478bd9Sstevel@tonic-gate 				   const struct ctl_verb *,
987c478bd9Sstevel@tonic-gate 				   u_int, u_int,
997c478bd9Sstevel@tonic-gate 				   u_int, int, int,
1007c478bd9Sstevel@tonic-gate 				   ctl_logfunc, void *);
1017c478bd9Sstevel@tonic-gate void			ctl_endserver(struct ctl_sctx *);
1027c478bd9Sstevel@tonic-gate void			ctl_response(struct ctl_sess *, u_int,
1037c478bd9Sstevel@tonic-gate 				     const char *, u_int, const void *,
1047c478bd9Sstevel@tonic-gate 				     ctl_srvrdone, void *,
1057c478bd9Sstevel@tonic-gate 				     const char *, size_t);
1067c478bd9Sstevel@tonic-gate void			ctl_sendhelp(struct ctl_sess *, u_int);
1077c478bd9Sstevel@tonic-gate void *			ctl_getcsctx(struct ctl_sess *);
1087c478bd9Sstevel@tonic-gate void *			ctl_setcsctx(struct ctl_sess *, void *);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #endif /*ISC_CTL_H*/
111*9525b14bSRao Shoaib 
112*9525b14bSRao Shoaib /*! \file */
113