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