xref: /openbsd-src/usr.sbin/dvmrpctl/parser.h (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1 /*	$OpenBSD: parser.h,v 1.1 2006/06/01 14:21:28 norby Exp $ */
2 
3 /*
4  * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
5  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _PARSER_H_
21 #define _PARSER_H_
22 
23 #include <sys/types.h>
24 #include <net/if.h>
25 #include <netinet/in.h>
26 
27 enum actions {
28 	NONE,
29 	SHOW,
30 	SHOW_SUM,
31 	SHOW_IFACE,
32 	SHOW_IFACE_DTAIL,
33 	SHOW_IGMP,
34 	SHOW_NBR,
35 	SHOW_NBR_DTAIL,
36 	SHOW_RIB,
37 	SHOW_RIB_DTAIL,
38 	SHOW_MFC,
39 	SHOW_MFC_DTAIL,
40 	RELOAD
41 };
42 
43 struct parse_result {
44 	struct in_addr	addr;
45 	char		ifname[IF_NAMESIZE];
46 	int		flags;
47 	enum actions	action;
48 	u_int8_t	prefixlen;
49 };
50 
51 struct parse_result	*parse(int, char *[]);
52 const struct token	*match_token(const char *, const struct token []);
53 void			 show_valid_args(const struct token []);
54 int			 parse_addr(const char *, struct in_addr *);
55 int			 parse_prefix(const char *, struct in_addr *,
56 			     u_int8_t *);
57 
58 #endif	/* _PARSER_H_ */
59