summaryrefslogtreecommitdiff
path: root/usr.sbin/ipftest/ipft_tx.c
diff options
context:
space:
mode:
authordgregor <dgregor@cvs.openbsd.org>1998-01-26 04:17:12 +0000
committerdgregor <dgregor@cvs.openbsd.org>1998-01-26 04:17:12 +0000
commitfe0239590c82ea51b1a09fd58cde9f1635ceab89 (patch)
treeaf8e00e22aa869bee7596358bc05686c76370f51 /usr.sbin/ipftest/ipft_tx.c
parenta344d388d075c3e901494684772107ed51830e00 (diff)
IPF 3.2.3
Diffstat (limited to 'usr.sbin/ipftest/ipft_tx.c')
-rw-r--r--usr.sbin/ipftest/ipft_tx.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/usr.sbin/ipftest/ipft_tx.c b/usr.sbin/ipftest/ipft_tx.c
index 8cc50b1acba..74cb4ee3cf6 100644
--- a/usr.sbin/ipftest/ipft_tx.c
+++ b/usr.sbin/ipftest/ipft_tx.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: ipft_tx.c,v 1.9 1997/06/23 01:37:35 deraadt Exp $ */
+/* $OpenBSD: ipft_tx.c,v 1.10 1998/01/26 04:16:38 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,32 +25,35 @@
#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 <arpa/inet.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_tx.c 1.7 6/5/96 (C) 1993 Darren Reed";
-static char rcsid[] = "$DRId: ipft_tx.c,v 2.0.1.3 1997/02/20 09:47:47 darrenr Exp $"
+#if !defined(lint)
+static const char sccsid[] = "@(#)ipft_tx.c 1.7 6/5/96 (C) 1993 Darren Reed";
+static const char rcsid[] = "@(#)$Id: ipft_tx.c,v 1.10 1998/01/26 04:16:38 dgregor Exp $";
#endif
extern int opts;
-extern u_long buildopts();
static char *tx_proto = "";
-static int text_open(), text_close(), text_readip(), parseline();
+static int text_open __P((char *)), text_close __P((void));
+static int text_readip __P((char *, int, char **, int *));
+static int parseline __P((char *, ip_t *, char **, int *));
static char tcp_flagset[] = "FSRPAU";
static u_char tcp_flags[] = { TH_FIN, TH_SYN, TH_RST, TH_PUSH,
@@ -59,15 +63,15 @@ struct ipread iptext = { text_open, text_close, text_readip };
static FILE *tfp = NULL;
static int tfd = -1;
-static in_addr_t tx_hostnum();
-static in_port_t tx_portnum();
+static u_long tx_hostnum __P((char *, int *));
+static u_short tx_portnum __P((char *));
/*
* returns an ip address as a long var as a result of either a DNS lookup or
* straight inet_addr() call
*/
-static in_addr_t tx_hostnum(host, resolved)
+static u_long tx_hostnum(host, resolved)
char *host;
int *resolved;
{
@@ -88,7 +92,7 @@ int *resolved;
}
return np->n_net;
}
- return *(in_addr_t *)hp->h_addr;
+ return *(u_32_t *)hp->h_addr;
}
@@ -96,7 +100,7 @@ int *resolved;
* find the port number given by the name, either from getservbyname() or
* straight atoi()
*/
-static in_port_t tx_portnum(name)
+static u_short tx_portnum(name)
char *name;
{
struct servent *sp, *sp2;
@@ -134,8 +138,8 @@ char *name;
char *tx_icmptypes[] = {
"echorep", (char *)NULL, (char *)NULL, "unreach", "squench",
- "redir", (char *)NULL, (char *)NULL, "echo", (char *)NULL,
- (char *)NULL, "timex", "paramprob", "timest", "timestrep",
+ "redir", (char *)NULL, (char *)NULL, "echo", "routerad",
+ "routersol", "timex", "paramprob", "timest", "timestrep",
"inforeq", "inforep", "maskreq", "maskrep", "END"
};
@@ -173,10 +177,10 @@ char *buf, **ifn;
int cnt, *dir;
{
register char *s;
- struct ip *ip;
+ ip_t *ip;
char line[513];
- ip = (struct ip *)buf;
+ ip = (ip_t *)buf;
*ifn = NULL;
while (fgets(line, sizeof(line)-1, tfp)) {
if ((s = index(line, '\n')))
@@ -191,11 +195,11 @@ int cnt, *dir;
printf("input: %s\n", line);
*ifn = NULL;
*dir = 0;
- if (!parseline(line, buf, ifn, dir))
+ if (!parseline(line, (ip_t *)buf, ifn, dir))
#if 0
return sizeof(struct tcpiphdr);
#else
- return sizeof(struct ip);
+ return sizeof(ip_t);
#endif
}
return -1;
@@ -203,7 +207,7 @@ int cnt, *dir;
static int parseline(line, ip, ifn, out)
char *line;
-struct ip *ip;
+ip_t *ip;
char **ifn;
int *out;
{
@@ -243,7 +247,7 @@ int *out;
}
c = **cpp;
- ip->ip_len = sizeof(struct ip);
+ ip->ip_len = sizeof(ip_t);
if (!strcasecmp(*cpp, "tcp") || !strcasecmp(*cpp, "udp") ||
!strcasecmp(*cpp, "icmp")) {
if (c == 't') {
@@ -325,7 +329,7 @@ int *out;
u_long olen;
cpp++;
- olen = buildopts(*cpp, ipopts);
+ olen = buildopts(*cpp, ipopts, (ip->ip_hl - 5) << 2);
if (olen) {
bcopy(ipopts, (char *)(ip + 1), olen);
ip->ip_hl += olen >> 2;