ngctl.h revision 53913
1234353Sdim
2218885Sdim/*
3218885Sdim * ngctl.h
4218885Sdim *
5218885Sdim * Copyright (c) 1996-1999 Whistle Communications, Inc.
6218885Sdim * All rights reserved.
7218885Sdim *
8218885Sdim * Subject to the following obligations and disclaimer of warranty, use and
9218885Sdim * redistribution of this software, in source or object code forms, with or
10218885Sdim * without modifications are expressly permitted by Whistle Communications;
11218885Sdim * provided, however, that:
12218885Sdim * 1. Any and all reproductions of the source or object code must include the
13218885Sdim *    copyright notice above and the following disclaimer of warranties; and
14218885Sdim * 2. No rights are granted, in any manner or form, to use Whistle
15218885Sdim *    Communications, Inc. trademarks, including the mark "WHISTLE
16218885Sdim *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
17218885Sdim *    such appears in the above copyright notice or in the software.
18218885Sdim *
19218885Sdim * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
20221345Sdim * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
21221345Sdim * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
22218885Sdim * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
23218885Sdim * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24218885Sdim * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
25234353Sdim * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
26234353Sdim * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
27234353Sdim * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
28234353Sdim * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
29223017Sdim * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30226633Sdim * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31218885Sdim * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32221345Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33221345Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34221345Sdim * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35221345Sdim * OF SUCH DAMAGE.
36218885Sdim *
37218885Sdim * $FreeBSD: head/usr.sbin/ngctl/ngctl.h 53913 1999-11-30 02:45:32Z archie $
38218885Sdim */
39218885Sdim
40218885Sdim#include <sys/types.h>
41218885Sdim#include <sys/param.h>
42218885Sdim#include <sys/time.h>
43243830Sdim#include <sys/socket.h>
44243830Sdim#include <sys/select.h>
45263508Sdim#include <sys/linker.h>
46263508Sdim
47218885Sdim#include <stdio.h>
48218885Sdim#include <stdlib.h>
49218885Sdim#include <string.h>
50218885Sdim#include <unistd.h>
51218885Sdim#include <sysexits.h>
52218885Sdim#include <limits.h>
53218885Sdim#include <ctype.h>
54218885Sdim#include <errno.h>
55218885Sdim#include <err.h>
56218885Sdim
57218885Sdim#include <netgraph.h>
58218885Sdim#include <netgraph/ng_socket.h>
59218885Sdim#include <netgraph/ng_message.h>
60218885Sdim
61218885Sdim#define MAX_CMD_ALIAS	8
62218885Sdim
63218885Sdim/* Command descriptors */
64218885Sdimstruct ngcmd {
65218885Sdim	  int		(*func)(int ac, char **av);	/* command function */
66218885Sdim	  const char	*cmd;				/* command usage */
67218885Sdim	  const char	*desc;				/* description */
68218885Sdim	  const char	*help;				/* help text */
69263508Sdim	  const char	*aliases[MAX_CMD_ALIAS];	/* command aliases */
70263508Sdim};
71263508Sdim
72218885Sdim/* Command return values */
73218885Sdim#define CMDRTN_OK		0
74218885Sdim#define CMDRTN_USAGE		1
75218885Sdim#define CMDRTN_ERROR		2
76218885Sdim#define CMDRTN_QUIT		3
77218885Sdim
78218885Sdim/* Available commands */
79218885Sdimextern const struct ngcmd connect_cmd;
80218885Sdimextern const struct ngcmd debug_cmd;
81218885Sdimextern const struct ngcmd help_cmd;
82218885Sdimextern const struct ngcmd list_cmd;
83218885Sdimextern const struct ngcmd mkpeer_cmd;
84218885Sdimextern const struct ngcmd msg_cmd;
85218885Sdimextern const struct ngcmd name_cmd;
86218885Sdimextern const struct ngcmd read_cmd;
87263508Sdimextern const struct ngcmd rmhook_cmd;
88263508Sdimextern const struct ngcmd show_cmd;
89263508Sdimextern const struct ngcmd shutdown_cmd;
90263508Sdimextern const struct ngcmd status_cmd;
91263508Sdimextern const struct ngcmd types_cmd;
92263508Sdimextern const struct ngcmd quit_cmd;
93263508Sdim
94263508Sdim/* Data and control sockets */
95263508Sdimextern int	csock, dsock;
96263508Sdim
97263508Sdim