2 * Copyright (C) 1995-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 #if defined(__sgi) && (IRIX > 602)
7 # include <sys/ptimers.h>
13 #include <sys/types.h>
14 #if !defined(__SVR4) && !defined(__svr4__)
17 #include <sys/byteorder.h>
19 #include <sys/param.h>
24 #include <sys/socket.h>
25 #include <sys/ioctl.h>
26 #include <netinet/in.h>
27 #include <netinet/in_systm.h>
29 #include <netinet/ip_var.h>
31 #include <netinet/ip.h>
32 #include <netinet/udp.h>
33 #include <netinet/tcp.h>
34 #include <netinet/ip_icmp.h>
37 #include <arpa/nameser.h>
39 #include "ip_compat.h"
40 #include <netinet/tcpip.h>
45 static const char sccsid[] = "@(#)ipft_hx.c 1.1 3/9/96 (C) 1996 Darren Reed";
46 static const char rcsid[] = "@(#)$Id: ipft_hx.c,v 2.2.2.6 2002/12/06 11:40:25 darrenr Exp $";
51 static int hex_open __P((char *));
52 static int hex_close __P((void));
53 static int hex_readip __P((char *, int, char **, int *));
54 static char *readhex __P((char *, char *));
56 struct ipread iphex = { hex_open, hex_close, hex_readip };
57 static FILE *tfp = NULL;
60 static int hex_open(fname)
63 if (tfp && tfd != -1) {
68 if (!strcmp(fname, "-")) {
72 tfd = open(fname, O_RDONLY);
74 tfp = fdopen(tfd, "r");
80 static int hex_close()
89 static int hex_readip(buf, cnt, ifn, dir)
93 register char *s, *t, *u;
98 * interpret start of line as possibly "[ifname]" or
106 while (fgets(line, sizeof(line)-1, tfp)) {
107 if ((s = index(line, '\n'))) {
109 return (char *)ip - buf;
112 if ((s = index(line, '#')))
116 if (!(opts & OPT_BRIEF)) {
117 printf("input: %s\n", line);
121 if ((*line == '[') && (s = index(line, ']'))) {
125 if ((u = index(t, ',')) && (u < s)) {
140 ip = (ip_t *)readhex(s, (char *)ip);
146 static char *readhex(src, dst)
147 register char *src, *dst;
152 while ((c = *src++)) {
159 } else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
160 (c >= 'A' && c <= 'F')) {
161 c = isdigit(c) ? (c - '0') : (toupper(c) - 55);