diff options
author | peter <peter@FreeBSD.org> | 1998-06-20 18:29:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-06-20 18:29:38 +0000 |
commit | 9529c38ad8859b9f325867d97f266101f2c4dca3 (patch) | |
tree | 7c9206c000e7ad493db842a3fecdf77deacb096a /contrib/ipfilter/parse.c | |
parent | 58e3555d887b6a5b1f460d8ee84ca4e97c0a8217 (diff) | |
download | FreeBSD-src-9529c38ad8859b9f325867d97f266101f2c4dca3.zip FreeBSD-src-9529c38ad8859b9f325867d97f266101f2c4dca3.tar.gz |
Import trimmed version of ipfilter 3.2.7.
Obtained from: Darren Reed via http://cheops.anu.edu.au/~avalon/
Diffstat (limited to 'contrib/ipfilter/parse.c')
-rw-r--r-- | contrib/ipfilter/parse.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/contrib/ipfilter/parse.c b/contrib/ipfilter/parse.c index bbc1925..76ee474 100644 --- a/contrib/ipfilter/parse.c +++ b/contrib/ipfilter/parse.c @@ -35,7 +35,7 @@ #if !defined(lint) static const char sccsid[] ="@(#)parse.c 1.44 6/5/96 (C) 1993-1996 Darren Reed"; -static const char rcsid[] = "@(#)$Id: parse.c,v 2.0.2.18.2.1 1997/11/20 12:43:49 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: parse.c,v 2.0.2.18.2.5 1998/05/23 19:20:33 darrenr Exp $"; #endif extern struct ipopt_names ionames[], secclass[]; @@ -57,7 +57,7 @@ int icmpcode __P((char *)), addkeep __P((char ***, struct frentry *)); int to_interface __P((frdest_t *, char *)); void print_toif __P((char *, frdest_t *)); void optprint __P((u_short, u_short, u_long, u_long)); -int countbits __P((u_long)); +int countbits __P((u_32_t)); char *portname __P((int, int)); @@ -475,12 +475,21 @@ char *line; /* * lazy users... */ - if (!fil.fr_proto && !(fil.fr_ip.fi_fl & FI_TCPUDP) && - (fil.fr_dcmp || fil.fr_scmp || fil.fr_tcpf)) { - (void)fprintf(stderr, - "no protocol given for TCP/UDP comparisons\n"); + if ((fil.fr_tcpf || fil.fr_tcpfm) && fil.fr_proto != IPPROTO_TCP) { + (void)fprintf(stderr, "TCP protocol not specified\n"); return NULL; } + if (!(fil.fr_ip.fi_fl & FI_TCPUDP) && (fil.fr_proto != IPPROTO_TCP) && + (fil.fr_proto != IPPROTO_UDP) && (fil.fr_dcmp || fil.fr_scmp)) { + if (!fil.fr_proto) { + fil.fr_ip.fi_fl |= FI_TCPUDP; + fil.fr_mip.fi_fl |= FI_TCPUDP; + } else { + (void)fprintf(stderr, + "port comparisons for non-TCP/UDP\n"); + return NULL; + } + } /* if ((fil.fr_flags & FR_KEEPFRAG) && (!(fil.fr_ip.fi_fl & FI_FRAG) || !(fil.fr_ip.fi_fl & FI_FRAG))) { @@ -621,7 +630,7 @@ int *resolved; fprintf(stderr, "can't resolve hostname: %s\n", host); return 0; } - return np->n_net; + return htonl(np->n_net); } return *(u_32_t *)hp->h_addr; } @@ -980,7 +989,6 @@ struct frentry *fp; fp->fr_proto = IPPROTO_ICMP; if (isdigit(***cp)) { i = atoi(**cp); - (*cp)++; } else { for (t = icmptypes, i = 0; ; t++, i++) { if (!*t) @@ -1082,9 +1090,9 @@ struct frentry *fp; * of bits. */ int countbits(ip) -u_long ip; +u_32_t ip; { - u_long ipn; + u_32_t ipn; int cnt = 0, i, j; ip = ipn = ntohl(ip); |