xref: /openbsd-src/usr.sbin/ripctl/parser.h (revision 6be5843ec61e3a3d3891b84615bd5eb6f8c55d63)
1*6be5843eStedu /*	$OpenBSD: parser.h,v 1.4 2010/09/04 21:31:04 tedu Exp $ */
28eeeb81eSnorby 
38eeeb81eSnorby /*
48eeeb81eSnorby  * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
58eeeb81eSnorby  * Copyright (c) 2004 Esben Norby <norby@openbsd.org>
68eeeb81eSnorby  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
78eeeb81eSnorby  *
88eeeb81eSnorby  * Permission to use, copy, modify, and distribute this software for any
98eeeb81eSnorby  * purpose with or without fee is hereby granted, provided that the above
108eeeb81eSnorby  * copyright notice and this permission notice appear in all copies.
118eeeb81eSnorby  *
128eeeb81eSnorby  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
138eeeb81eSnorby  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
148eeeb81eSnorby  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
158eeeb81eSnorby  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
168eeeb81eSnorby  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
178eeeb81eSnorby  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
188eeeb81eSnorby  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
198eeeb81eSnorby  */
208eeeb81eSnorby 
218eeeb81eSnorby #ifndef _PARSER_H_
228eeeb81eSnorby #define _PARSER_H_
238eeeb81eSnorby 
248eeeb81eSnorby #include <sys/types.h>
258eeeb81eSnorby #include <net/if.h>
268eeeb81eSnorby #include <netinet/in.h>
278eeeb81eSnorby 
288eeeb81eSnorby enum actions {
298eeeb81eSnorby 	NONE,
308eeeb81eSnorby 	FIB,
318eeeb81eSnorby 	FIB_COUPLE,
328eeeb81eSnorby 	FIB_DECOUPLE,
33c3319070Sclaudio 	LOG_VERBOSE,
34c3319070Sclaudio 	LOG_BRIEF,
358eeeb81eSnorby 	SHOW,
368eeeb81eSnorby 	SHOW_IFACE,
378eeeb81eSnorby 	SHOW_NBR,
388eeeb81eSnorby 	SHOW_RIB,
398eeeb81eSnorby 	SHOW_FIB,
408eeeb81eSnorby 	SHOW_FIB_IFACE,
418eeeb81eSnorby 	RELOAD
428eeeb81eSnorby };
438eeeb81eSnorby 
448eeeb81eSnorby struct parse_result {
458eeeb81eSnorby 	struct in_addr	addr;
468eeeb81eSnorby 	char		ifname[IF_NAMESIZE];
478eeeb81eSnorby 	int		flags;
488eeeb81eSnorby 	enum actions	action;
498eeeb81eSnorby 	u_int8_t	prefixlen;
508eeeb81eSnorby };
518eeeb81eSnorby 
528eeeb81eSnorby struct parse_result	*parse(int, char *[]);
538eeeb81eSnorby int			 parse_addr(const char *, struct in_addr *);
548eeeb81eSnorby int			 parse_prefix(const char *, struct in_addr *,
558eeeb81eSnorby 			     u_int8_t *);
568eeeb81eSnorby 
578eeeb81eSnorby #endif	/* _PARSER_H_ */
58