diff options
author | Cy Schubert <cy@FreeBSD.org> | 2013-08-11 14:28:45 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2013-08-11 14:28:45 +0000 |
commit | 05ddbb8d93073fe6263bb3fff26e1c4c8651352e (patch) | |
tree | 1edb84380ee8d48a5e93a53f33d1b6373e330d5e /lib/ipft_hx.c | |
parent | c63520fcdd8c7ba7a737717520fa3896db69342f (diff) | |
download | src-05ddbb8d93073fe6263bb3fff26e1c4c8651352e.tar.gz src-05ddbb8d93073fe6263bb3fff26e1c4c8651352e.zip |
Import IP-Filter 5.1.2 into vendor branches using the existing license that
the current version of IP-Filter in FreeBSD is under as per email received
from Darren Reed on Mon, 08 Jul 2013 23:54:16 +1000.
Approved by: glebius (Mentor), Darren Reed <darrenr@reed.wattle.id.au>
Notes
Notes:
svn path=/vendor/ipfilter/dist/; revision=254219
Diffstat (limited to 'lib/ipft_hx.c')
-rw-r--r-- | lib/ipft_hx.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/lib/ipft_hx.c b/lib/ipft_hx.c index 4851fff3eae4..18fee1e64a0a 100644 --- a/lib/ipft_hx.c +++ b/lib/ipft_hx.c @@ -1,11 +1,11 @@ /* - * Copyright (C) 2000-2005 by Darren Reed. + * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. */ #if !defined(lint) static const char sccsid[] = "@(#)ipft_hx.c 1.1 3/9/96 (C) 1996 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ipft_hx.c,v 1.11.4.4 2006/06/16 17:21:03 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id$"; #endif #include <ctype.h> @@ -18,7 +18,7 @@ extern int opts; static int hex_open __P((char *)); static int hex_close __P((void)); -static int hex_readip __P((char *, int, char **, int *)); +static int hex_readip __P((mb_t *, char **, int *)); static char *readhex __P((char *, char *)); struct ipread iphex = { hex_open, hex_close, hex_readip, 0 }; @@ -26,7 +26,7 @@ static FILE *tfp = NULL; static int tfd = -1; static int hex_open(fname) -char *fname; + char *fname; { if (tfp && tfd != -1) { rewind(tfp); @@ -54,14 +54,19 @@ static int hex_close() } -static int hex_readip(buf, cnt, ifn, dir) -char *buf, **ifn; -int cnt, *dir; +static int hex_readip(mb, ifn, dir) + mb_t *mb; + char **ifn; + int *dir; { register char *s, *t, *u; char line[513]; ip_t *ip; + char *buf; + int cnt; + buf = (char *)mb->mb_buf; + cnt = sizeof(mb->mb_buf); /* * interpret start of line as possibly "[ifname]" or * "[in/out,ifname]". @@ -73,8 +78,10 @@ int cnt, *dir; ip = (ip_t *)buf; while (fgets(line, sizeof(line)-1, tfp)) { if ((s = strchr(line, '\n'))) { - if (s == line) - return (char *)ip - buf; + if (s == line) { + mb->mb_len = (char *)ip - buf; + return mb->mb_len; + } *s = '\0'; } if ((s = strchr(line, '#'))) @@ -102,17 +109,35 @@ int cnt, *dir; } else if (ifn) *ifn = t; } + + while (*s++ == '+') { + if (!strncasecmp(s, "mcast", 5)) { + mb->mb_flags |= M_MCAST; + s += 5; + } + if (!strncasecmp(s, "bcast", 5)) { + mb->mb_flags |= M_BCAST; + s += 5; + } + if (!strncasecmp(s, "mbcast", 6)) { + mb->mb_flags |= M_MBCAST; + s += 6; + } + } + while (ISSPACE(*s)) + s++; } else s = line; t = (char *)ip; ip = (ip_t *)readhex(s, (char *)ip); if ((opts & OPT_DEBUG) != 0) { if (opts & OPT_ASCII) { + int c = *t; if (t < (char *)ip) putchar('\t'); while (t < (char *)ip) { - if (ISPRINT(*t) && ISASCII(*t)) - putchar(*t); + if (isprint(c) && isascii(c)) + putchar(c); else putchar('.'); t++; |