1 /* $OpenBSD: pfctl_parser.h,v 1.7 2001/08/11 09:54:59 deraadt Exp $ */ 2 3 /* 4 * Copyright (c) 2001, Daniel Hartmeier 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 */ 32 33 #ifndef _PFCTL_PARSER_H_ 34 #define _PFCTL_PARSER_H_ 35 36 struct pfctl { 37 int dev; 38 int opts; 39 struct pfioc_rule *prule; 40 struct pfioc_nat *pnat; 41 struct pfioc_rdr *prdr; 42 }; 43 44 int pfctl_add_rule(struct pfctl *, struct pf_rule *); 45 int pfctl_add_nat(struct pfctl *, struct pf_nat *); 46 int pfctl_add_rdr(struct pfctl *, struct pf_rdr *); 47 48 int parse_rules(FILE *, struct pfctl *); 49 int parse_nat(FILE *, struct pfctl *); 50 int parse_flags(char *); 51 52 void print_rule(struct pf_rule *); 53 void print_nat(struct pf_nat *); 54 void print_rdr(struct pf_rdr *); 55 void print_state(struct pf_state *); 56 void print_status(struct pf_status *); 57 58 struct icmptypeent { 59 char *name; 60 u_int8_t type; 61 }; 62 63 struct icmpcodeent { 64 char *name; 65 u_int8_t type; 66 u_int8_t code; 67 }; 68 69 struct icmptypeent *geticmptypebynumber(u_int8_t); 70 struct icmptypeent *geticmptypebyname(char *); 71 struct icmpcodeent *geticmpcodebynumber(u_int8_t, u_int8_t); 72 struct icmpcodeent *geticmpcodebyname(u_long, char *); 73 74 #endif /* _PFCTL_PARSER_H_ */ 75