summaryrefslogtreecommitdiff
path: root/usr.sbin/ipftest/ipft_hx.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ipftest/ipft_hx.c')
-rw-r--r--usr.sbin/ipftest/ipft_hx.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/usr.sbin/ipftest/ipft_hx.c b/usr.sbin/ipftest/ipft_hx.c
index c828e429a01..94b5eb5c3ca 100644
--- a/usr.sbin/ipftest/ipft_hx.c
+++ b/usr.sbin/ipftest/ipft_hx.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: ipft_hx.c,v 1.5 1997/06/23 16:44:48 kstailey Exp $ */
+/* $OpenBSD: ipft_hx.c,v 1.6 1998/01/26 04:16:34 dgregor Exp $ */
/*
- * (C)opyright 1995 by Darren Reed.
+ * Copyright (C) 1995-1997 by Darren Reed.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and due credit is given
@@ -10,13 +10,14 @@
#include <ctype.h>
#include <assert.h>
#include <string.h>
+#include <sys/types.h>
#if !defined(__SVR4) && !defined(__svr4__)
#include <strings.h>
#else
#include <sys/byteorder.h>
#endif
-#include <sys/types.h>
#include <sys/param.h>
+#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
@@ -24,30 +25,33 @@
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
+#ifndef linux
#include <netinet/ip_var.h>
+#endif
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <netinet/ip_icmp.h>
-#include <netinet/tcpip.h>
#include <net/if.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <resolv.h>
+#include "ip_fil_compat.h"
+#include <netinet/tcpip.h>
#include "ipf.h"
#include "ipt.h"
-#if !defined(lint) && defined(LIBC_SCCS)
-static char sccsid[] = "@(#)ipft_hx.c 1.1 3/9/96 (C) 1996 Darren Reed";
-static char rcsid[] = "$DRId: ipft_hx.c,v 2.0.1.2 1997/02/04 13:57:56 darrenr Exp $";
+#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.6 1998/01/26 04:16:34 dgregor Exp $";
#endif
extern int opts;
-extern u_short portnum();
-extern u_long buildopts();
-static int hex_open(), hex_close(), hex_readip();
-static char *readhex();
+static int hex_open __P((char *));
+static int hex_close __P((void));
+static int hex_readip __P((char *, int, char **, int *));
+static char *readhex __P((char *, char *));
struct ipread iphex = { hex_open, hex_close, hex_readip };
static FILE *tfp = NULL;
@@ -86,11 +90,11 @@ static int hex_readip(buf, cnt, ifn, dir)
char *buf, **ifn;
int cnt, *dir;
{
- register char *s;
- struct ip *ip;
+ register char *s, *t, *u;
char line[513];
+ ip_t *ip;
- ip = (struct ip *)buf;
+ ip = (ip_t *)buf;
while (fgets(line, sizeof(line)-1, tfp)) {
if ((s = index(line, '\n'))) {
if (s == line)
@@ -105,7 +109,35 @@ int cnt, *dir;
printf("input: %s\n", line);
fflush(stdout);
}
- ip = (struct ip *)readhex(line, (char *)ip);
+
+ /*
+ * interpret start of line as possibly "[ifname]" or
+ * "[in/out,ifname]".
+ */
+ if (ifn)
+ *ifn = NULL;
+ if (dir)
+ *dir = 0;
+ if ((*buf == '[') && (s = index(line, ']'))) {
+ t = buf + 1;
+ if (t - s > 0) {
+ if ((u = index(t, ',')) && (u < s)) {
+ u++;
+ if (ifn)
+ *ifn = u;
+ if (dir) {
+ if (*t == 'i')
+ *dir = 0;
+ else if (*t == 'o')
+ *dir = 1;
+ }
+ } else if (ifn)
+ *ifn = t;
+ *s++ = '\0';
+ }
+ } else
+ s = line;
+ ip = (ip_t *)readhex(s, (char *)ip);
}
return -1;
}