1 /* 2 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 3 * 4 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 5 * 6 * Redistribution and use in source and binary forms are permitted 7 * provided that the above copyright notice and this paragraph are 8 * duplicated in all such forms and that any documentation, 9 * advertising materials, and other materials related to such 10 * distribution and use acknowledge that the software was developed 11 * by the Internet Initiative Japan. The name of the 12 * IIJ may not be used to endorse or promote products derived 13 * from this software without specific prior written permission. 14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 * 18 * $Id: filter.h,v 1.11.2.6 1998/04/18 01:01:20 brian Exp $ 19 * 20 * TODO: 21 */ 22 23 /* 24 * Actions 25 */ 26 #define A_NONE 0 27 #define A_PERMIT 1 28 #define A_DENY 2 29 #define A_MASK 3 30 #define A_UHOST 4 31 #define A_UPORT 8 32 33 /* 34 * Known protocols 35 */ 36 #define P_NONE 0 37 #define P_TCP 1 38 #define P_UDP 2 39 #define P_ICMP 3 40 41 /* 42 * Operations 43 */ 44 #define OP_NONE 0 45 #define OP_EQ 1 46 #define OP_GT 2 47 #define OP_LT 4 48 49 struct filterent { 50 int action; /* Filtering action */ 51 int swidth; /* Effective source address width */ 52 struct in_addr saddr; /* Source address */ 53 struct in_addr smask; /* Source address mask */ 54 int dwidth; /* Effective destination address width */ 55 struct in_addr daddr; /* Destination address */ 56 struct in_addr dmask; /* Destination address mask */ 57 int proto; /* Protocol */ 58 struct { 59 short srcop; 60 u_short srcport; 61 short dstop; 62 u_short dstport; 63 unsigned estab : 1; 64 unsigned syn : 1; 65 unsigned finrst : 1; 66 } opt; 67 }; 68 69 #define MAXFILTERS 20 /* in each filter set */ 70 71 struct filter { 72 struct filterent rule[MAXFILTERS]; /* incoming packet filter */ 73 const char *name; 74 unsigned fragok : 1; 75 unsigned logok : 1; 76 }; 77 78 #define FL_IN 0 79 #define FL_OUT 1 80 #define FL_DIAL 2 81 #define FL_KEEP 3 82 83 struct ipcp; 84 struct cmdargs; 85 86 extern int ParseAddr(struct ipcp *, int, char const *const *, struct in_addr *, 87 struct in_addr *, int *); 88 extern int filter_Show(struct cmdargs const *); 89 extern int filter_Set(struct cmdargs const *); 90 extern const char * filter_Action2Nam(int); 91 extern const char *filter_Proto2Nam(int); 92 extern const char *filter_Op2Nam(int); 93