summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/ipsend
diff options
context:
space:
mode:
authordarrenr <darrenr@FreeBSD.org>2005-04-25 17:31:50 +0000
committerdarrenr <darrenr@FreeBSD.org>2005-04-25 17:31:50 +0000
commitd438802dcb3e270d6fcc65f075c808c64853a7c2 (patch)
treee2e1c7115044e6dfc86ff65598566fa32e5f7421 /contrib/ipfilter/ipsend
parent590450fec65a8e72a8965117398bc8f14938b4a8 (diff)
downloadFreeBSD-src-d438802dcb3e270d6fcc65f075c808c64853a7c2.zip
FreeBSD-src-d438802dcb3e270d6fcc65f075c808c64853a7c2.tar.gz
import ipfilter 4.1.8 into the vendor branch
Diffstat (limited to 'contrib/ipfilter/ipsend')
-rw-r--r--contrib/ipfilter/ipsend/.OLD/ip_compat.h2
-rw-r--r--contrib/ipfilter/ipsend/.cvsignore3
-rw-r--r--contrib/ipfilter/ipsend/44arp.c37
-rw-r--r--contrib/ipfilter/ipsend/Makefile12
-rw-r--r--contrib/ipfilter/ipsend/arp.c35
-rw-r--r--contrib/ipfilter/ipsend/dlcommon.c30
-rw-r--r--contrib/ipfilter/ipsend/dltest.h2
-rw-r--r--contrib/ipfilter/ipsend/hpux.c6
-rw-r--r--contrib/ipfilter/ipsend/in_var.h4
-rw-r--r--contrib/ipfilter/ipsend/ip.c98
-rw-r--r--contrib/ipfilter/ipsend/ip_var.h4
-rw-r--r--contrib/ipfilter/ipsend/ipresend.12
-rw-r--r--contrib/ipfilter/ipsend/ipresend.c33
-rw-r--r--contrib/ipfilter/ipsend/ipsend.12
-rw-r--r--contrib/ipfilter/ipsend/ipsend.54
-rw-r--r--contrib/ipfilter/ipsend/ipsend.c117
-rw-r--r--contrib/ipfilter/ipsend/ipsend.h24
-rw-r--r--contrib/ipfilter/ipsend/ipsopt.c28
-rw-r--r--contrib/ipfilter/ipsend/iptest.12
-rw-r--r--contrib/ipfilter/ipsend/iptest.c33
-rw-r--r--contrib/ipfilter/ipsend/iptests.c199
-rw-r--r--contrib/ipfilter/ipsend/larp.c14
-rw-r--r--contrib/ipfilter/ipsend/linux.h6
-rw-r--r--contrib/ipfilter/ipsend/lsock.c10
-rw-r--r--contrib/ipfilter/ipsend/resend.c41
-rw-r--r--contrib/ipfilter/ipsend/sbpf.c33
-rw-r--r--contrib/ipfilter/ipsend/sdlpi.c69
-rw-r--r--contrib/ipfilter/ipsend/sirix.c12
-rw-r--r--contrib/ipfilter/ipsend/slinux.c9
-rw-r--r--contrib/ipfilter/ipsend/snit.c9
-rw-r--r--contrib/ipfilter/ipsend/sock.c52
-rw-r--r--contrib/ipfilter/ipsend/sockraw.c89
-rw-r--r--contrib/ipfilter/ipsend/tcpip.h15
33 files changed, 617 insertions, 419 deletions
diff --git a/contrib/ipfilter/ipsend/.OLD/ip_compat.h b/contrib/ipfilter/ipsend/.OLD/ip_compat.h
index c38fa59..3b62be1 100644
--- a/contrib/ipfilter/ipsend/.OLD/ip_compat.h
+++ b/contrib/ipfilter/ipsend/.OLD/ip_compat.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1995 by Darren Reed.
*
diff --git a/contrib/ipfilter/ipsend/.cvsignore b/contrib/ipfilter/ipsend/.cvsignore
new file mode 100644
index 0000000..b7aea24
--- /dev/null
+++ b/contrib/ipfilter/ipsend/.cvsignore
@@ -0,0 +1,3 @@
+ipsend
+ipresend
+iptest
diff --git a/contrib/ipfilter/ipsend/44arp.c b/contrib/ipfilter/ipsend/44arp.c
index de9f4d9..4206355 100644
--- a/contrib/ipfilter/ipsend/44arp.c
+++ b/contrib/ipfilter/ipsend/44arp.c
@@ -1,33 +1,37 @@
+/* $NetBSD$ */
+
/*
* Based upon 4.4BSD's /usr/sbin/arp
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
-#endif
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
+#if __FreeBSD_version >= 300000
+# include <net/if_var.h>
+#endif
#include <net/if_dl.h>
#include <net/if_types.h>
+#if defined(__FreeBSD__)
+# include "radix_ipf.h"
+#endif
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
#include <netdb.h>
#include <errno.h>
#include <nlist.h>
#include <stdio.h>
-#include <netinet/in.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#if __FreeBSD_version >= 300000
-# include <net/if_var.h>
-#endif
#include "ipsend.h"
#include "iplang/iplang.h"
@@ -37,7 +41,7 @@
* its IP address in address
* (4 bytes)
*/
-int resolve(host, address)
+int resolve(host, address)
char *host, *address;
{
struct hostent *hp;
@@ -74,6 +78,9 @@ char *addr, *eaddr;
return 0;
#endif
+ if (!addr)
+ return -1;
+
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
@@ -101,8 +108,8 @@ char *addr, *eaddr;
rtm = (struct rt_msghdr *)next;
sin = (struct sockaddr_inarp *)(rtm + 1);
sdl = (struct sockaddr_dl *)(sin + 1);
- if (addr && !bcmp(addr, (char *)&sin->sin_addr,
- sizeof(struct in_addr)))
+ if (!bcmp(addr, (char *)&sin->sin_addr,
+ sizeof(struct in_addr)))
{
bcopy(LLADDR(sdl), eaddr, sdl->sdl_alen);
return 0;
diff --git a/contrib/ipfilter/ipsend/Makefile b/contrib/ipfilter/ipsend/Makefile
index bb8000f..ed3a51e 100644
--- a/contrib/ipfilter/ipsend/Makefile
+++ b/contrib/ipfilter/ipsend/Makefile
@@ -1,9 +1,7 @@
#
# Copyright (C) 1993-1998 by Darren Reed.
#
-# Redistribution and use in source and binary forms are permitted
-# provided that this notice is preserved and due credit is given
-# to the original author and the contributors.
+# See the IPFILTER.LICENCE file for details on licencing.
#
IPFT=ipft_ef.o ipft_hx.o ipft_pc.o ipft_sn.o ipft_td.o ipft_tx.o opt.o
OBJS=ipsend.o ip.o ipsopt.o y.tab.o lex.yy.o
@@ -134,6 +132,14 @@ hpux9 :
make iptest "TOBJS=$(TOBJS)" "UNIXOBJS=$(HPUX)" "CC=$(CC)" \
CFLAGS="$(CFLAGS)" "LIBS="
+hpux11 :
+ make ipsend "OBJS=$(OBJS)" "UNIXOBJS=$(HPUX)" "CC=$(CC)" \
+ CFLAGS="$(CFLAGS) -DIPSEND" "LIBS="
+ make ipresend "ROBJS=$(ROBJS)" "UNIXOBJS=$(HPUX)" "CC=$(CC)" \
+ CFLAGS="$(CFLAGS)" "LIBS="
+ make iptest "TOBJS=$(TOBJS)" "UNIXOBJS=$(HPUX)" "CC=$(CC)" \
+ CFLAGS="$(CFLAGS)" "LIBS="
+
ipsend: ipf $(OBJS) $(UNIXOBJS)
$(CC) $(OBJS) $(UNIXOBJS) -o $@ $(LIBS) $(LLIB) $(ELIB)
diff --git a/contrib/ipfilter/ipsend/arp.c b/contrib/ipfilter/ipsend/arp.c
index 8e5f7f4..0e8f556 100644
--- a/contrib/ipfilter/ipsend/arp.c
+++ b/contrib/ipfilter/ipsend/arp.c
@@ -1,20 +1,21 @@
+/* $NetBSD$ */
+
/*
* arp.c (C) 1995-1998 Darren Reed
*
* See the IPFILTER.LICENCE file for details on licencing.
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "@(#)arp.c 1.4 1/11/96 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: arp.c,v 2.8 2003/12/01 02:01:15 darrenr Exp";
#endif
-#include <stdio.h>
-#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
-#if !defined(ultrix) && !defined(hpux)
+#if !defined(ultrix) && !defined(hpux) && !defined(__hpux) && !defined(__osf__)
#include <sys/sockio.h>
#endif
#include <sys/ioctl.h>
-#include <netdb.h>
+#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <net/if.h>
#include <netinet/if_ether.h>
@@ -22,23 +23,22 @@
#include <net/if_arp.h>
#endif
#include <netinet/in.h>
+#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
+#include <stdio.h>
+#include <errno.h>
+#include <netdb.h>
#include "ipsend.h"
#include "iplang/iplang.h"
-#if !defined(lint)
-static const char sccsid[] = "@(#)arp.c 1.4 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: arp.c,v 2.1.4.4 2002/12/06 11:40:35 darrenr Exp $";
-#endif
-
/*
* lookup host and return
* its IP address in address
* (4 bytes)
*/
-int resolve(host, address)
+int resolve(host, address)
char *host, *address;
{
struct hostent *hp;
@@ -90,7 +90,11 @@ char *ether;
bcopy(ip, (char *)&sin->sin_addr.s_addr, 4);
#ifndef hpux
if ((hp = gethostbyaddr(ip, 4, AF_INET)))
+# if SOLARIS && (SOLARIS2 >= 10)
+ if (!(ether_hostton(hp->h_name, (struct ether_addr *)ether)))
+# else
if (!(ether_hostton(hp->h_name, ether)))
+# endif
goto savearp;
#endif
@@ -122,6 +126,13 @@ tryagain:
return -1;
}
+ if ((ar.arp_ha.sa_data[0] == 0) && (ar.arp_ha.sa_data[1] == 0) &&
+ (ar.arp_ha.sa_data[2] == 0) && (ar.arp_ha.sa_data[3] == 0) &&
+ (ar.arp_ha.sa_data[4] == 0) && (ar.arp_ha.sa_data[5] == 0)) {
+ fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
+ return -1;
+ }
+
bcopy(ar.arp_ha.sa_data, ether, 6);
savearp:
bcopy(ether, ethersave, 6);
diff --git a/contrib/ipfilter/ipsend/dlcommon.c b/contrib/ipfilter/ipsend/dlcommon.c
index 59b283d..6e351f0 100644
--- a/contrib/ipfilter/ipsend/dlcommon.c
+++ b/contrib/ipfilter/ipsend/dlcommon.c
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/*
* Common (shared) DLPI test routines.
* Mostly pretty boring boilerplate sorta stuff.
@@ -18,7 +20,11 @@ typedef unsigned long ulong;
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
-#include <sys/dlpi.h>
+#ifdef __osf__
+# include <sys/dlpihdr.h>
+#else
+# include <sys/dlpi.h>
+#endif
#include <sys/signal.h>
#include <stdio.h>
#include <string.h>
@@ -35,6 +41,7 @@ char *dlstyle();
char *dlmactype();
+void
dlinforeq(fd)
int fd;
{
@@ -54,6 +61,7 @@ int fd;
syserr("dlinforeq: putmsg");
}
+void
dlinfoack(fd, bufp)
int fd;
char *bufp;
@@ -82,6 +90,7 @@ char *bufp;
err("dlinfoack: short response ctl.len: %d", ctl.len);
}
+void
dlattachreq(fd, ppa)
int fd;
u_long ppa;
@@ -103,6 +112,7 @@ u_long ppa;
syserr("dlattachreq: putmsg");
}
+void
dlenabmultireq(fd, addr, length)
int fd;
char *addr;
@@ -131,6 +141,7 @@ int length;
syserr("dlenabmultireq: putmsg");
}
+void
dldisabmultireq(fd, addr, length)
int fd;
char *addr;
@@ -159,6 +170,7 @@ int length;
syserr("dldisabmultireq: putmsg");
}
+void
dlpromisconreq(fd, level)
int fd;
u_long level;
@@ -181,6 +193,7 @@ u_long level;
}
+void
dlpromiscoff(fd, level)
int fd;
u_long level;
@@ -202,6 +215,7 @@ u_long level;
syserr("dlpromiscoff: putmsg");
}
+void
dlphysaddrreq(fd, addrtype)
int fd;
u_long addrtype;
@@ -223,6 +237,7 @@ u_long addrtype;
syserr("dlphysaddrreq: putmsg");
}
+void
dlsetphysaddrreq(fd, addr, length)
int fd;
char *addr;
@@ -251,6 +266,7 @@ int length;
syserr("dlsetphysaddrreq: putmsg");
}
+void
dldetachreq(fd)
int fd;
{
@@ -270,6 +286,7 @@ int fd;
syserr("dldetachreq: putmsg");
}
+void
dlbindreq(fd, sap, max_conind, service_mode, conn_mgmt, xidtest)
int fd;
u_long sap;
@@ -299,6 +316,7 @@ u_long xidtest;
syserr("dlbindreq: putmsg");
}
+void
dlunitdatareq(fd, addrp, addrlen, minpri, maxpri, datap, datalen)
int fd;
u_char *addrp;
@@ -333,6 +351,7 @@ int datalen;
syserr("dlunitdatareq: putmsg");
}
+void
dlunbindreq(fd)
int fd;
{
@@ -352,6 +371,7 @@ int fd;
syserr("dlunbindreq: putmsg");
}
+void
dlokack(fd, bufp)
int fd;
char *bufp;
@@ -380,6 +400,7 @@ char *bufp;
err("dlokack: short response ctl.len: %d", ctl.len);
}
+void
dlerrorack(fd, bufp)
int fd;
char *bufp;
@@ -408,6 +429,7 @@ char *bufp;
err("dlerrorack: short response ctl.len: %d", ctl.len);
}
+void
dlbindack(fd, bufp)
int fd;
char *bufp;
@@ -433,6 +455,7 @@ char *bufp;
err("dlbindack: short response ctl.len: %d", ctl.len);
}
+void
dlphysaddrack(fd, bufp)
int fd;
char *bufp;
@@ -695,10 +718,11 @@ union DL_primitives *dlp;
printdlerrorack(dlp)
union DL_primitives *dlp;
{
- (void) printf("DL_ERROR_ACK: error_primitive %s errno %s unix_errno %d\n",
+ (void) printf("DL_ERROR_ACK: error_primitive %s errno %s unix_errno %d: %s\n",
dlprim(dlp->error_ack.dl_error_primitive),
dlerrno(dlp->error_ack.dl_errno),
- dlp->error_ack.dl_unix_errno);
+ dlp->error_ack.dl_unix_errno,
+ strerror(dlp->error_ack.dl_unix_errno));
}
printdlenabmultireq(dlp)
diff --git a/contrib/ipfilter/ipsend/dltest.h b/contrib/ipfilter/ipsend/dltest.h
index 4c32c30..9fafd91 100644
--- a/contrib/ipfilter/ipsend/dltest.h
+++ b/contrib/ipfilter/ipsend/dltest.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/*
* Common DLPI Test Suite header file
*
diff --git a/contrib/ipfilter/ipsend/hpux.c b/contrib/ipfilter/ipsend/hpux.c
index 463fdbf..69f962c 100644
--- a/contrib/ipfilter/ipsend/hpux.c
+++ b/contrib/ipfilter/ipsend/hpux.c
@@ -1,7 +1,11 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1997-1998 Darren Reed. (from tcplog)
*
- * See the IPFILTER.LICENCE file for details on licencing.
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and due credit is given
+ * to the original author and the contributors.
*/
#include <stdio.h>
#include <strings.h>
diff --git a/contrib/ipfilter/ipsend/in_var.h b/contrib/ipfilter/ipsend/in_var.h
index b935259..f228bbb 100644
--- a/contrib/ipfilter/ipsend/in_var.h
+++ b/contrib/ipfilter/ipsend/in_var.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/* @(#)in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86 */
/*
@@ -173,5 +175,5 @@ struct in_multistep {
}
struct in_multi *in_addmulti();
-#endif KERNEL
+#endif /* KERNEL */
#endif /*!_netinet_in_var_h*/
diff --git a/contrib/ipfilter/ipsend/ip.c b/contrib/ipfilter/ipsend/ip.c
index 8d30bf5..8302806 100644
--- a/contrib/ipfilter/ipsend/ip.c
+++ b/contrib/ipfilter/ipsend/ip.c
@@ -1,25 +1,21 @@
+/* $NetBSD$ */
+
/*
* ip.c (C) 1995-1998 Darren Reed
*
* See the IPFILTER.LICENCE file for details on licencing.
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "%W% %G% (C)1995";
+static const char rcsid[] = "@(#)Id: ip.c,v 2.8.2.1 2004/10/19 12:31:48 darrenr Exp";
#endif
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <netinet/in_systm.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
#include <sys/param.h>
#ifndef linux
# include <netinet/if_ether.h>
@@ -28,12 +24,13 @@
# include <net/if_var.h>
# endif
#endif
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "%W% %G% (C)1995";
-static const char rcsid[] = "@(#)$Id: ip.c,v 2.1.4.5 2002/12/06 11:40:35 darrenr Exp $";
-#endif
static char *ipbuf = NULL, *ethbuf = NULL;
@@ -71,7 +68,9 @@ struct in_addr gwip;
bcopy((char *)buf, s + sizeof(*eh), len);
if (gwip.s_addr == last_gw.s_addr)
+ {
bcopy(last_arp, (char *)A_A eh->ether_dhost, 6);
+ }
else if (arp((char *)&gwip, (char *)A_A eh->ether_dhost) == -1)
{
perror("arp");
@@ -92,7 +91,8 @@ ip_t *ip;
struct in_addr gwip;
int frag;
{
- static struct in_addr last_gw;
+ static struct in_addr last_gw, local_ip;
+ static char local_arp[6] = { 0, 0, 0, 0, 0, 0};
static char last_arp[6] = { 0, 0, 0, 0, 0, 0};
static u_short id = 0;
ether_header_t *eh;
@@ -102,7 +102,7 @@ int frag;
if (!ipbuf)
{
ipbuf = (char *)malloc(65536);
- if(!ipbuf)
+ if (!ipbuf)
{
perror("malloc failed");
return -2;
@@ -113,7 +113,9 @@ int frag;
bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost));
if (last_gw.s_addr && (gwip.s_addr == last_gw.s_addr))
+ {
bcopy(last_arp, (char *)A_A eh->ether_dhost, 6);
+ }
else if (arp((char *)&gwip, (char *)A_A eh->ether_dhost) == -1)
{
perror("arp");
@@ -127,18 +129,25 @@ int frag;
iplen = ip->ip_len;
ip->ip_len = htons(iplen);
if (!(frag & 2)) {
- if (!ip->ip_v)
- ip->ip_v = IPVERSION;
+ if (!IP_V(ip))
+ IP_V_A(ip, IPVERSION);
if (!ip->ip_id)
ip->ip_id = htons(id++);
if (!ip->ip_ttl)
ip->ip_ttl = 60;
}
+ if (ip->ip_src.s_addr != local_ip.s_addr) {
+ (void) arp((char *)&ip->ip_src, (char *)A_A local_arp);
+ bcopy(local_arp, (char *)A_A eh->ether_shost,sizeof(last_arp));
+ local_ip = ip->ip_src;
+ } else
+ bcopy(local_arp, (char *)A_A eh->ether_shost, 6);
+
if (!frag || (sizeof(*eh) + iplen < mtu))
{
ip->ip_sum = 0;
- ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
bcopy((char *)ip, ipbuf + sizeof(*eh), iplen);
err = sendip(nfd, ipbuf, sizeof(*eh) + iplen);
@@ -155,14 +164,14 @@ int frag;
char *s;
int i, sent = 0, ts, hlen, olen;
- hlen = ip->ip_hl << 2;
+ hlen = IP_HL(ip) << 2;
if (mtu < (hlen + 8)) {
fprintf(stderr, "mtu (%d) < ip header size (%d) + 8\n",
mtu, hlen);
fprintf(stderr, "can't fragment data\n");
return -2;
}
- ol = (ip->ip_hl << 2) - sizeof(*ip);
+ ol = (IP_HL(ip) << 2) - sizeof(*ip);
for (i = 0, s = (char*)(ip + 1); ol > 0; )
if (*s == IPOPT_EOL) {
optcpy[i++] = *s;
@@ -223,7 +232,7 @@ int frag;
else if (!(ip->ip_off & htons(0x1fff)))
{
hlen = i + sizeof(*ip);
- ip->ip_hl = (sizeof(*ip) + i) >> 2;
+ IP_HL_A(ip, (sizeof(*ip) + i) >> 2);
bcopy(optcpy, (char *)(ip + 1), i);
}
}
@@ -243,45 +252,46 @@ ip_t *ip;
struct in_addr gwip;
{
static tcp_seq iss = 2;
- struct tcpiphdr *ti;
- tcphdr_t *t;
+ tcphdr_t *t, *t2;
int thlen, i, iplen, hlen;
u_32_t lbuf[20];
+ ip_t *ip2;
iplen = ip->ip_len;
- hlen = ip->ip_hl << 2;
+ hlen = IP_HL(ip) << 2;
t = (tcphdr_t *)((char *)ip + hlen);
- ti = (struct tcpiphdr *)lbuf;
- thlen = t->th_off << 2;
+ ip2 = (struct ip *)lbuf;
+ t2 = (tcphdr_t *)((char *)ip2 + hlen);
+ thlen = TCP_OFF(t) << 2;
if (!thlen)
thlen = sizeof(tcphdr_t);
- bzero((char *)ti, sizeof(*ti));
+ bzero((char *)ip2, sizeof(*ip2) + sizeof(*t2));
ip->ip_p = IPPROTO_TCP;
- ti->ti_pr = ip->ip_p;
- ti->ti_src = ip->ip_src;
- ti->ti_dst = ip->ip_dst;
- bcopy((char *)ip + hlen, (char *)&ti->ti_sport, thlen);
+ ip2->ip_p = ip->ip_p;
+ ip2->ip_src = ip->ip_src;
+ ip2->ip_dst = ip->ip_dst;
+ bcopy((char *)ip + hlen, (char *)t2, thlen);
- if (!ti->ti_win)
- ti->ti_win = htons(4096);
+ if (!t2->th_win)
+ t2->th_win = htons(4096);
iss += 63;
i = sizeof(struct tcpiphdr) / sizeof(long);
- if ((ti->ti_flags == TH_SYN) && !ntohs(ip->ip_off) &&
+ if ((t2->th_flags == TH_SYN) && !ntohs(ip->ip_off) &&
(lbuf[i] != htonl(0x020405b4))) {
lbuf[i] = htonl(0x020405b4);
bcopy((char *)ip + hlen + thlen, (char *)ip + hlen + thlen + 4,
iplen - thlen - hlen);
thlen += 4;
}
- ti->ti_off = thlen >> 2;
- ti->ti_len = htons(thlen);
+ TCP_OFF_A(t2, thlen >> 2);
+ ip2->ip_len = htons(thlen);
ip->ip_len = hlen + thlen;
- ti->ti_sum = 0;
- ti->ti_sum = chksum((u_short *)ti, thlen + sizeof(ip_t));
+ t2->th_sum = 0;
+ t2->th_sum = chksum((u_short *)ip2, thlen + sizeof(ip_t));
- bcopy((char *)&ti->ti_sport, (char *)ip + hlen, thlen);
+ bcopy((char *)t2, (char *)ip + hlen, thlen);
return send_ip(nfd, mtu, ip, gwip, 1);
}
@@ -304,16 +314,16 @@ struct in_addr gwip;
ti->ti_pr = ip->ip_p;
ti->ti_src = ip->ip_src;
ti->ti_dst = ip->ip_dst;
- bcopy((char *)ip + (ip->ip_hl << 2),
+ bcopy((char *)ip + (IP_HL(ip) << 2),
(char *)&ti->ti_sport, sizeof(udphdr_t));
ti->ti_len = htons(thlen);
- ip->ip_len = (ip->ip_hl << 2) + thlen;
+ ip->ip_len = (IP_HL(ip) << 2) + thlen;
ti->ti_sum = 0;
ti->ti_sum = chksum((u_short *)ti, thlen + sizeof(ip_t));
bcopy((char *)&ti->ti_sport,
- (char *)ip + (ip->ip_hl << 2), sizeof(udphdr_t));
+ (char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t));
return send_ip(nfd, mtu, ip, gwip, 1);
}
@@ -328,7 +338,7 @@ struct in_addr gwip;
{
struct icmp *ic;
- ic = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
+ ic = (struct icmp *)((char *)ip + (IP_HL(ip) << 2));
ic->icmp_cksum = 0;
ic->icmp_cksum = chksum((u_short *)ic, sizeof(struct icmp));
diff --git a/contrib/ipfilter/ipsend/ip_var.h b/contrib/ipfilter/ipsend/ip_var.h
index ace9800..b08f4e7 100644
--- a/contrib/ipfilter/ipsend/ip_var.h
+++ b/contrib/ipfilter/ipsend/ip_var.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/* @(#)ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86 */
/*
@@ -44,7 +46,7 @@ struct ipq {
* Note: ipf_next must be at same offset as ipq_next above
*/
struct ipasfrag {
-#if defined(vax) || defined(i386) || defined(__i386__)
+#if defined(vax) || defined(i386)
u_char ip_hl:4,
ip_v:4;
#endif
diff --git a/contrib/ipfilter/ipsend/ipresend.1 b/contrib/ipfilter/ipsend/ipresend.1
index 6014313..cffc6f3 100644
--- a/contrib/ipfilter/ipsend/ipresend.1
+++ b/contrib/ipfilter/ipsend/ipresend.1
@@ -1,3 +1,5 @@
+.\" $NetBSD$
+.\"
.TH IPRESEND 1
.SH NAME
ipresend \- resend IP packets out to network
diff --git a/contrib/ipfilter/ipsend/ipresend.c b/contrib/ipfilter/ipsend/ipresend.c
index 9252b4b..1db54e1 100644
--- a/contrib/ipfilter/ipsend/ipresend.c
+++ b/contrib/ipfilter/ipsend/ipresend.c
@@ -1,42 +1,33 @@
+/* $NetBSD$ */
+
/*
* ipresend.c (C) 1995-1998 Darren Reed
*
- * This was written to test what size TCP fragments would get through
- * various TCP/IP packet filters, as used in IP firewalls. In certain
- * conditions, enough of the TCP header is missing for unpredictable
- * results unless the filter is aware that this can happen.
- *
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: ipresend.c,v 2.4 2004/01/08 13:34:31 darrenr Exp";
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/types.h>
#include <sys/param.h>
+#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <string.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ipresend.c,v 2.1.4.4 2002/12/06 11:40:35 darrenr Exp $";
-#endif
-
extern char *optarg;
extern int optind;
diff --git a/contrib/ipfilter/ipsend/ipsend.1 b/contrib/ipfilter/ipsend/ipsend.1
index f2f8066..33320f3 100644
--- a/contrib/ipfilter/ipsend/ipsend.1
+++ b/contrib/ipfilter/ipsend/ipsend.1
@@ -1,3 +1,5 @@
+.\" $NetBSD$
+.\"
.TH IPSEND 1
.SH NAME
ipsend \- sends IP packets
diff --git a/contrib/ipfilter/ipsend/ipsend.5 b/contrib/ipfilter/ipsend/ipsend.5
index f713147..aac757a 100644
--- a/contrib/ipfilter/ipsend/ipsend.5
+++ b/contrib/ipfilter/ipsend/ipsend.5
@@ -1,3 +1,5 @@
+.\" $NetBSD$
+.\"
.TH IPSEND 5
.SH NAME
ipsend \- IP packet description language
@@ -358,7 +360,7 @@ should be routing packets via another route. The redirect code names are:
Echo.
.TP
.B routerad
-Router Advertisment.
+Router Advertisement.
.TP
.B routersol
Router solicitation.
diff --git a/contrib/ipfilter/ipsend/ipsend.c b/contrib/ipfilter/ipsend/ipsend.c
index cdf18a7..6c91d4d 100644
--- a/contrib/ipfilter/ipsend/ipsend.c
+++ b/contrib/ipfilter/ipsend/ipsend.c
@@ -1,21 +1,14 @@
+/* $NetBSD$ */
+
/*
* ipsend.c (C) 1995-1998 Darren Reed
*
- * This was written to test what size TCP fragments would get through
- * various TCP/IP packet filters, as used in IP firewalls. In certain
- * conditions, enough of the TCP header is missing for unpredictable
- * results unless the filter is aware that this can happen.
- *
* See the IPFILTER.LICENCE file for details on licencing.
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "@(#)ipsend.c 1.5 12/10/95 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: ipsend.c,v 2.8.2.2 2004/11/13 16:50:10 darrenr Exp";
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <string.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -23,20 +16,19 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in_systm.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <string.h>
#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/ip_icmp.h>
#ifndef linux
-#include <netinet/ip_var.h>
+# include <netinet/ip_var.h>
#endif
#include "ipsend.h"
-
-#if !defined(lint)
-static const char sccsid[] = "@(#)ipsend.c 1.5 12/10/95 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ipsend.c,v 2.2.2.7 2004/04/10 11:50:52 darrenr Exp $";
+#include "ipf.h"
+#ifndef linux
+# include <netinet/udp_var.h>
#endif
@@ -46,27 +38,27 @@ extern void iplang __P((FILE *));
char options[68];
int opts;
-#ifdef linux
+#ifdef linux
char default_device[] = "eth0";
#else
-# ifdef sun
-char default_device[] = "le0";
-# else
-# ifdef ultrix
+# ifdef ultrix
char default_device[] = "ln0";
-# else
-# ifdef __bsdi__
+# else
+# ifdef __bsdi__
char default_device[] = "ef0";
-# else
-# ifdef __sgi
+# else
+# ifdef __sgi
char default_device[] = "ec0";
-# else
+# else
+# ifdef __hpux
char default_device[] = "lan0";
-# endif
-# endif
-# endif
-# endif
-#endif
+# else
+char default_device[] = "le0";
+# endif /* __hpux */
+# endif /* __sgi */
+# endif /* __bsdi__ */
+# endif /* ultrix */
+#endif /* linux */
static void usage __P((char *));
@@ -161,13 +153,9 @@ int mtu;
ip_t *ip;
struct in_addr gwip;
{
- u_short sport = 0;
- int wfd;
-
- if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
- sport = ((struct tcpiphdr *)ip)->ti_sport;
- wfd = initdevice(dev, sport, 5);
+ int wfd;
+ wfd = initdevice(dev, 5);
return send_packet(wfd, mtu, ip, gwip);
}
@@ -185,7 +173,7 @@ udpcksum(ip_t *ip, struct udphdr *udp, int len)
u_short w[6];
} ph;
u_32_t temp32;
- u_short cksum, *opts;
+ u_short *opts;
ph.h.len = htons(len);
ph.h.ttl = 0;
@@ -208,8 +196,6 @@ int argc;
char **argv;
{
FILE *langfile = NULL;
- struct tcpiphdr *ti;
- struct udpiphdr *ui;
struct in_addr gwip;
tcphdr_t *tcp;
udphdr_t *udp;
@@ -223,15 +209,12 @@ char **argv;
* 65535 is maximum packet size...you never know...
*/
ip = (ip_t *)calloc(1, 65536);
- ti = (struct tcpiphdr *)ip;
- ui = (struct udpiphdr *)ip;
- tcp = (tcphdr_t *)&ti->ti_sport;
- udp = (udphdr_t *)&ui->ui_sport;
- ui->ui_ulen = htons(sizeof(*udp));
+ tcp = (tcphdr_t *)(ip + 1);
+ udp = (udphdr_t *)tcp;
ip->ip_len = sizeof(*ip);
- ip->ip_hl = sizeof(*ip) >> 2;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
- while ((c = getopt(argc, argv, "I:L:P:TUdf:i:g:m:o:s:t:vw:")) != -1)
+ while ((c = getopt(argc, argv, "I:L:P:TUdf:i:g:m:o:s:t:vw:")) != -1) {
switch (c)
{
case 'I' :
@@ -325,7 +308,7 @@ char **argv;
break;
case 'o' :
nonl++;
- olen = buildopts(optarg, options, (ip->ip_hl - 5) << 2);
+ olen = buildopts(optarg, options, (IP_HL(ip) - 5) << 2);
break;
case 's' :
nonl++;
@@ -350,6 +333,7 @@ char **argv;
fprintf(stderr, "Unknown option \"%c\"\n", c);
usage(name);
}
+ }
if (argc - optind < 1)
usage(name);
@@ -381,11 +365,6 @@ char **argv;
exit(2);
}
- if (ip->ip_p != IPPROTO_TCP && ip->ip_p != IPPROTO_UDP) {
- fprintf(stderr,"Unsupported protocol %d\n", ip->ip_p);
- exit(2);
- }
-
if (olen)
{
int hlen;
@@ -393,22 +372,24 @@ char **argv;
printf("Options: %d\n", olen);
hlen = sizeof(*ip) + olen;
- ip->ip_hl = hlen >> 2;
+ IP_HL_A(ip, hlen >> 2);
ip->ip_len += olen;
p = (char *)malloc(65536);
- if(!p)
+ if (p == NULL)
{
- fprintf(stderr,"malloc failed\n");
+ fprintf(stderr, "malloc failed\n");
exit(2);
- }
+ }
+
bcopy(ip, p, sizeof(*ip));
bcopy(options, p + sizeof(*ip), olen);
bcopy(ip + 1, p + hlen, ip->ip_len - hlen);
ip = (ip_t *)p;
+
if (ip->ip_p == IPPROTO_TCP) {
- tcp = (tcphdr_t *)((char *)ip + hlen);
- } else {
- udp = (udphdr_t *)((char *)ip + hlen);
+ tcp = (tcphdr_t *)(p + hlen);
+ } else if (ip->ip_p == IPPROTO_UDP) {
+ udp = (udphdr_t *)(p + hlen);
}
}
@@ -448,11 +429,11 @@ char **argv;
if (ip->ip_p == IPPROTO_UDP) {
udp->uh_sum = 0;
- udpcksum(ip, udp, (ip->ip_len) - (ip->ip_hl << 2));
+ udpcksum(ip, udp, ip->ip_len - (IP_HL(ip) << 2));
}
#ifdef DOSOCKET
if (ip->ip_p == IPPROTO_TCP && tcp->th_dport)
- return do_socket(dev, mtu, (struct tcpiphdr *)ip, gwip);
+ return do_socket(dev, mtu, ip, gwip);
#endif
return send_packets(dev, mtu, ip, gwip);
}
diff --git a/contrib/ipfilter/ipsend/ipsend.h b/contrib/ipfilter/ipsend/ipsend.h
index 71e5490..be98c1b 100644
--- a/contrib/ipfilter/ipsend/ipsend.h
+++ b/contrib/ipfilter/ipsend/ipsend.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/*
* ipsend.h (C) 1997-1998 Darren Reed
*
@@ -6,7 +8,11 @@
* conditions, enough of the TCP header is missing for unpredictable
* results unless the filter is aware that this can happen.
*
- * See the IPFILTER.LICENCE file for details on licencing.
+ * The author provides this program as-is, with no gaurantee for its
+ * suitability for any specific purpose. The author takes no responsibility
+ * for the misuse/abuse of this program and provides it for the sole purpose
+ * of testing packet filter policies. This file maybe distributed freely
+ * providing it is not modified and that this notice remains in tact.
*
*/
#ifndef __P
@@ -17,13 +23,14 @@
# endif
#endif
-#include "ip_compat.h"
+#include <net/if.h>
+
+#include "ipf.h"
#ifdef linux
#include <linux/sockios.h>
#endif
#include "tcpip.h"
#include "ipt.h"
-#include "ipf.h"
extern int resolve __P((char *, char *));
extern int arp __P((char *, char *));
@@ -35,10 +42,10 @@ extern int send_udp __P((int, int, ip_t *, struct in_addr));
extern int send_icmp __P((int, int, ip_t *, struct in_addr));
extern int send_packet __P((int, int, ip_t *, struct in_addr));
extern int send_packets __P((char *, int, ip_t *, struct in_addr));
-extern u_short seclevel __P((char *));
+extern u_short ipseclevel __P((char *));
extern u_32_t buildopts __P((char *, char *, int));
extern int addipopt __P((char *, struct ipopt_names *, int, char *));
-extern int initdevice __P((char *, int, int));
+extern int initdevice __P((char *, int));
extern int sendip __P((int, char *, int));
#ifdef linux
extern struct sock *find_tcp __P((int, struct tcpiphdr *));
@@ -55,7 +62,6 @@ extern void ip_test5 __P((char *, int, ip_t *, struct in_addr, int));
extern void ip_test6 __P((char *, int, ip_t *, struct in_addr, int));
extern void ip_test7 __P((char *, int, ip_t *, struct in_addr, int));
extern int do_socket __P((char *, int, struct tcpiphdr *, struct in_addr));
-extern int openkmem __P((void));
extern int kmemcpy __P((char *, void *, int));
#define KMCPY(a,b,c) kmemcpy((char *)(a), (void *)(b), (int)(c))
@@ -63,9 +69,3 @@ extern int kmemcpy __P((char *, void *, int));
#ifndef OPT_RAW
#define OPT_RAW 0x80000
#endif
-
-#ifndef __STDC__
-# ifndef const
-# define const
-# endif
-#endif
diff --git a/contrib/ipfilter/ipsend/ipsopt.c b/contrib/ipfilter/ipsend/ipsopt.c
index 144c86f..7f16705 100644
--- a/contrib/ipfilter/ipsend/ipsopt.c
+++ b/contrib/ipfilter/ipsend/ipsopt.c
@@ -1,21 +1,25 @@
+/* $NetBSD$ */
+
/*
* Copyright (C) 1995-1998 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "@(#)ipsopt.c 1.2 1/11/96 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: ipsopt.c,v 2.4.4.1 2004/03/23 12:58:05 darrenr Exp";
#endif
#include <sys/param.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
#ifndef linux
#include <netinet/ip_var.h>
#endif
@@ -23,9 +27,13 @@
#include <arpa/inet.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "@(#)ipsopt.c 1.2 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ipsopt.c,v 2.1.4.5 2004/04/10 11:50:52 darrenr Exp $";
+
+#ifndef __P
+# ifdef __STDC__
+# define __P(x) x
+# else
+# define __P(x) ()
+# endif
#endif
@@ -53,7 +61,7 @@ struct ipopt_names secnames[] = {
};
-u_short seclevel(slevel)
+u_short ipseclevel(slevel)
char *slevel;
{
struct ipopt_names *so;
@@ -108,7 +116,7 @@ char *class;
switch (io->on_value)
{
case IPOPT_SECURITY :
- lvl = seclevel(class);
+ lvl = ipseclevel(class);
*(op - 1) = lvl;
break;
case IPOPT_LSRR :
diff --git a/contrib/ipfilter/ipsend/iptest.1 b/contrib/ipfilter/ipsend/iptest.1
index ca74094..0af5cc2 100644
--- a/contrib/ipfilter/ipsend/iptest.1
+++ b/contrib/ipfilter/ipsend/iptest.1
@@ -1,3 +1,5 @@
+.\" $NetBSD$
+.\"
.TH IPTEST 1
.SH NAME
iptest \- automatically generate a packets to test IP functionality
diff --git a/contrib/ipfilter/ipsend/iptest.c b/contrib/ipfilter/ipsend/iptest.c
index 72d0d78..45f8f3a 100644
--- a/contrib/ipfilter/ipsend/iptest.c
+++ b/contrib/ipfilter/ipsend/iptest.c
@@ -1,21 +1,15 @@
+/* $NetBSD$ */
+
/*
* ipsend.c (C) 1995-1998 Darren Reed
*
- * This was written to test what size TCP fragments would get through
- * various TCP/IP packet filters, as used in IP firewalls. In certain
- * conditions, enough of the TCP header is missing for unpredictable
- * results unless the filter is aware that this can happen.
- *
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: iptest.c,v 2.6 2004/01/08 13:34:31 darrenr Exp";
#endif
-#include <stdio.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -24,22 +18,19 @@
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
#endif
#ifdef linux
#include <linux/sockios.h>
#endif
+#include <stdio.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: iptest.c,v 2.2.2.4 2002/12/06 11:40:35 darrenr Exp $";
-#endif
-
extern char *optarg;
extern int optind;
@@ -111,7 +102,7 @@ char **argv;
ip = (ip_t *)calloc(1, 65536);
ti = (struct tcpiphdr *)ip;
ip->ip_len = sizeof(*ip);
- ip->ip_hl = sizeof(*ip) >> 2;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
while ((c = getopt(argc, argv, "1234567d:g:m:p:s:")) != -1)
switch (c)
diff --git a/contrib/ipfilter/ipsend/iptests.c b/contrib/ipfilter/ipsend/iptests.c
index a2f8432..a6cb41a 100644
--- a/contrib/ipfilter/ipsend/iptests.c
+++ b/contrib/ipfilter/ipsend/iptests.c
@@ -1,35 +1,38 @@
+/* $NetBSD$ */
+
/*
* Copyright (C) 1993-1998 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: iptests.c,v 2.8.2.3 2004/04/16 23:33:04 darrenr Exp";
#endif
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/param.h>
-#define _KERNEL
-#define KERNEL
-#if !defined(solaris) && !defined(linux) && !defined(__sgi)
-# include <sys/file.h>
-#else
-# ifdef solaris
-# include <sys/dditypes.h>
+#if !defined(__osf__)
+# define _KERNEL
+# define KERNEL
+# if !defined(solaris) && !defined(linux) && !defined(__sgi) && !defined(hpux)
+# include <sys/file.h>
+# else
+# ifdef solaris
+# include <sys/dditypes.h>
+# endif
# endif
+# undef _KERNEL
+# undef KERNEL
#endif
-#undef _KERNEL
-#undef KERNEL
#if !defined(solaris) && !defined(linux) && !defined(__sgi)
# include <nlist.h>
# include <sys/user.h>
# include <sys/proc.h>
#endif
-#if !defined(ultrix) && !defined(hpux) && !defined(linux) && !defined(__sgi)
+#if !defined(ultrix) && !defined(hpux) && !defined(linux) && \
+ !defined(__sgi) && !defined(__osf__)
# include <kvm.h>
#endif
#ifndef ultrix
@@ -50,11 +53,17 @@
#endif
#include <netinet/in_systm.h>
#include <sys/socket.h>
+#ifdef __hpux
+# define _NET_ROUTE_INCLUDED
+#endif
#include <net/if.h>
#if defined(linux) && (LINUX >= 0200)
# include <asm/atomic.h>
#endif
#if !defined(linux)
+# if defined(__FreeBSD__)
+# include "radix_ipf.h"
+# endif
# include <net/route.h>
#else
# define __KERNEL__ /* because there's a macro not wrapped by this */
@@ -63,35 +72,38 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
-#ifndef linux
+#if !defined(linux)
# include <netinet/ip_var.h>
-# include <netinet/in_pcb.h>
-# include <netinet/tcp_timer.h>
-# include <netinet/tcp_var.h>
+# if !defined(__hpux)
+# include <netinet/in_pcb.h>
+# endif
#endif
#if defined(__SVR4) || defined(__svr4__) || defined(__sgi)
# include <sys/sysmacros.h>
#endif
-#if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000000)
-# define USE_NANOSLEEP
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __hpux
+# undef _NET_ROUTE_INCLUDED
#endif
#include "ipsend.h"
-
-#if !defined(lint)
-static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: iptests.c,v 2.1.4.8 2002/12/06 11:40:35 darrenr Exp $";
+#if !defined(linux) && !defined(__hpux)
+# include <netinet/tcp_timer.h>
+# include <netinet/tcp_var.h>
+#endif
+#if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000000)
+# define USE_NANOSLEEP
#endif
-#ifdef USE_NANOSLEEP
-# define PAUSE() ts.tv_sec = 0; ts.tv_nsec = 10000000; \
+#ifdef USE_NANOSLEEP
+# define PAUSE() ts.tv_sec = 0; ts.tv_nsec = 10000000; \
(void) nanosleep(&ts, NULL)
#else
# define PAUSE() tv.tv_sec = 0; tv.tv_usec = 10000; \
- (void) select(0, NULL, NULL, NULL, &tv)
+ (void) select(0, NULL, NULL, NULL, &tv)
#endif
@@ -102,7 +114,7 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -110,8 +122,8 @@ int ptest;
udphdr_t *u;
int nfd, i = 0, len, id = getpid();
- ip->ip_hl = sizeof(*ip) >> 2;
- ip->ip_v = IPVERSION;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
+ IP_V_A(ip, IPVERSION);
ip->ip_tos = 0;
ip->ip_off = 0;
ip->ip_ttl = 60;
@@ -124,7 +136,7 @@ int ptest;
u->uh_ulen = htons(sizeof(*u) + 4);
ip->ip_len = sizeof(*ip) + ntohs(u->uh_ulen);
len = ip->ip_len;
- nfd = initdevice(dev, u->uh_sport, 1);
+ nfd = initdevice(dev, 1);
if (!ptest || (ptest == 1)) {
/*
@@ -133,7 +145,7 @@ int ptest;
ip->ip_id = 0;
printf("1.1. sending packets with ip_hl < ip_len\n");
for (i = 0; i < ((sizeof(*ip) + ntohs(u->uh_ulen)) >> 2); i++) {
- ip->ip_hl = i >> 2;
+ IP_HL_A(ip, i >> 2);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
@@ -149,7 +161,7 @@ int ptest;
ip->ip_id = 0;
printf("1.2. sending packets with ip_hl > ip_len\n");
for (; i < ((sizeof(*ip) * 2 + ntohs(u->uh_ulen)) >> 2); i++) {
- ip->ip_hl = i >> 2;
+ IP_HL_A(ip, i >> 2);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
@@ -164,9 +176,9 @@ int ptest;
*/
ip->ip_id = 0;
printf("1.3. ip_v < 4\n");
- ip->ip_hl = sizeof(*ip) >> 2;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
for (i = 0; i < 4; i++) {
- ip->ip_v = i;
+ IP_V_A(ip, i);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
@@ -182,7 +194,7 @@ int ptest;
ip->ip_id = 0;
printf("1.4. ip_v > 4\n");
for (i = 5; i < 16; i++) {
- ip->ip_v = i;
+ IP_V_A(ip, i);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
@@ -196,13 +208,13 @@ int ptest;
* Part5: len < packet
*/
ip->ip_id = 0;
- ip->ip_v = IPVERSION;
+ IP_V_A(ip, IPVERSION);
i = ip->ip_len + 1;
printf("1.5.0 ip_len < packet size (size++, long packets)\n");
for (; i < (ip->ip_len * 2); i++) {
ip->ip_id = htons(id++);
ip->ip_sum = 0;
- ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
(void) send_ether(nfd, (char *)ip, i, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -214,7 +226,7 @@ int ptest;
ip->ip_id = htons(id++);
ip->ip_len = i;
ip->ip_sum = 0;
- ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
(void) send_ether(nfd, (char *)ip, len, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -233,7 +245,7 @@ int ptest;
ip->ip_id = htons(id++);
ip->ip_len = i;
ip->ip_sum = 0;
- ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
(void) send_ether(nfd, (char *)ip, len, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -245,7 +257,7 @@ int ptest;
for (i = len; i > 0; i--) {
ip->ip_id = htons(id++);
ip->ip_sum = 0;
- ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
(void) send_ether(nfd, (char *)ip, i, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -314,14 +326,14 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (63 * 1024 + 768); i += 768) {
- ip->ip_off = htons(IP_MF | ((i >> 3) & 0x1fff));
+ ip->ip_off = htons(IP_MF | (i >> 3));
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = htons((i >> 3) & 0x1fff);
+ ip->ip_off = htons(i >> 3);
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
putchar('\n');
@@ -348,7 +360,7 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (63 * 1024 + 768); i += 768) {
- ip->ip_off = htons(IP_MF | ((i >> 3) & 0x1fff));
+ ip->ip_off = htons(IP_MF | (i >> 3));
if ((rand() & 0x1f) != 0) {
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
@@ -358,7 +370,7 @@ int ptest;
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = htons((i >> 3) & 0x1fff);
+ ip->ip_off = htons(i >> 3);
if ((rand() & 0x1f) != 0) {
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
@@ -385,14 +397,14 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (32 * 1024 + 768); i += 768) {
- ip->ip_off = htons(IP_MF | ((i >> 3) & 0x1fff));
+ ip->ip_off = htons(IP_MF | (i >> 3));
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = htons((i >> 3) & 0x1fff);
+ ip->ip_off = htons(i >> 3);
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
putchar('\n');
@@ -450,7 +462,7 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -459,10 +471,10 @@ int ptest;
u_char *s;
s = (u_char *)(ip + 1);
- nfd = initdevice(dev, htons(1), 1);
+ nfd = initdevice(dev, 1);
- ip->ip_hl = 6;
- ip->ip_len = ip->ip_hl << 2;
+ IP_HL_A(ip, 6);
+ ip->ip_len = IP_HL(ip) << 2;
s[IPOPT_OPTVAL] = IPOPT_NOP;
s++;
if (!ptest || (ptest == 1)) {
@@ -480,8 +492,8 @@ int ptest;
PAUSE();
}
- ip->ip_hl = 7;
- ip->ip_len = ip->ip_hl << 2;
+ IP_HL_A(ip, 7);
+ ip->ip_len = IP_HL(ip) << 2;
if (!ptest || (ptest == 1)) {
/*
* Test 2: options have length = 0
@@ -545,7 +557,7 @@ int ptest;
{
static int ict1[10] = { 8, 9, 10, 13, 14, 15, 16, 17, 18, 0 };
static int ict2[8] = { 3, 9, 10, 13, 14, 17, 18, 0 };
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -553,16 +565,16 @@ int ptest;
struct icmp *icp;
int nfd, i;
- ip->ip_hl = sizeof(*ip) >> 2;
- ip->ip_v = IPVERSION;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
+ IP_V_A(ip, IPVERSION);
ip->ip_tos = 0;
ip->ip_off = 0;
ip->ip_ttl = 60;
ip->ip_p = IPPROTO_ICMP;
ip->ip_sum = 0;
ip->ip_len = sizeof(*ip) + sizeof(*icp);
- icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
- nfd = initdevice(dev, htons(1), 1);
+ icp = (struct icmp *)((char *)ip + (IP_HL(ip) << 2));
+ nfd = initdevice(dev, 1);
if (!ptest || (ptest == 1)) {
/*
@@ -741,7 +753,7 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -750,25 +762,25 @@ int ptest;
int nfd, i;
- ip->ip_hl = sizeof(*ip) >> 2;
- ip->ip_v = IPVERSION;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
+ IP_V_A(ip, IPVERSION);
ip->ip_tos = 0;
ip->ip_off = 0;
ip->ip_ttl = 60;
ip->ip_p = IPPROTO_UDP;
ip->ip_sum = 0;
- u = (udphdr_t *)((char *)ip + (ip->ip_hl << 2));
+ u = (udphdr_t *)((char *)ip + (IP_HL(ip) << 2));
u->uh_sport = htons(1);
u->uh_dport = htons(1);
u->uh_ulen = htons(sizeof(*u) + 4);
- nfd = initdevice(dev, u->uh_sport, 1);
+ nfd = initdevice(dev, 1);
if (!ptest || (ptest == 1)) {
/*
* Test 1. ulen > packet
*/
u->uh_ulen = htons(sizeof(*u) + 4);
- ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
+ ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen);
printf("4.1 UDP uh_ulen > packet size - short packets\n");
for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) {
u->uh_ulen = htons(i);
@@ -785,7 +797,7 @@ int ptest;
* Test 2. ulen < packet
*/
u->uh_ulen = htons(sizeof(*u) + 4);
- ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
+ ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen);
printf("4.2 UDP uh_ulen < packet size - short packets\n");
for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) {
ip->ip_len = i;
@@ -803,7 +815,7 @@ int ptest;
* sport = 32768, sport = 65535
*/
u->uh_ulen = sizeof(*u) + 4;
- ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
+ ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen);
printf("4.3.1 UDP sport = 0\n");
u->uh_sport = 0;
(void) send_udp(nfd, 1500, ip, gwip);
@@ -844,7 +856,7 @@ int ptest;
*/
u->uh_ulen = ntohs(sizeof(*u) + 4);
u->uh_sport = htons(1);
- ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
+ ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen);
printf("4.4.1 UDP dport = 0\n");
u->uh_dport = 0;
(void) send_udp(nfd, 1500, ip, gwip);
@@ -903,7 +915,7 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -911,11 +923,11 @@ int ptest;
tcphdr_t *t;
int nfd, i;
- t = (tcphdr_t *)((char *)ip + (ip->ip_hl << 2));
-#ifndef linux
+ t = (tcphdr_t *)((char *)ip + (IP_HL(ip) << 2));
+#if !defined(linux) && !defined(__osf__)
t->th_x2 = 0;
#endif
- t->th_off = 0;
+ TCP_OFF_A(t, 0);
t->th_sport = htons(1);
t->th_dport = htons(1);
t->th_win = htons(4096);
@@ -924,13 +936,13 @@ int ptest;
t->th_seq = htonl(1);
t->th_ack = 0;
ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t);
- nfd = initdevice(dev, t->th_sport, 1);
+ nfd = initdevice(dev, 1);
if (!ptest || (ptest == 1)) {
/*
* Test 1: flags variations, 0 - 3f
*/
- t->th_off = sizeof(*t) >> 2;
+ TCP_OFF_A(t, sizeof(*t) >> 2);
printf("5.1 Test TCP flag combinations\n");
for (i = 0; i <= (TH_URG|TH_ACK|TH_PUSH|TH_RST|TH_SYN|TH_FIN);
i++) {
@@ -1054,14 +1066,13 @@ int ptest;
}
#if !defined(linux) && !defined(__SVR4) && !defined(__svr4__) && \
- !defined(__sgi)
+ !defined(__sgi) && !defined(__hpux) && !defined(__osf__)
{
struct tcpcb *tcbp, tcb;
struct tcpiphdr ti;
struct sockaddr_in sin;
int fd, slen;
- fd = -1;
bzero((char *)&sin, sizeof(sin));
for (i = 1; i < 63; i++) {
@@ -1130,7 +1141,7 @@ int ptest;
t->th_flags = TH_ACK;
printf("5.6.1 TCP off = 1-15, len = 40\n");
for (i = 1; i < 16; i++) {
- ti.ti_off = ntohs(i);
+ TCP_OFF_A(t, ntohs(i));
(void) send_tcp(nfd, mtu, ip, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -1146,7 +1157,7 @@ skip_five_and_six:
#endif
t->th_seq = htonl(1);
t->th_ack = htonl(1);
- t->th_off = 0;
+ TCP_OFF_A(t, 0);
if (!ptest || (ptest == 7)) {
t->th_flags = TH_SYN;
@@ -1250,7 +1261,7 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
@@ -1258,7 +1269,7 @@ int ptest;
udphdr_t *u;
int nfd, i, j, k;
- ip->ip_v = IPVERSION;
+ IP_V_A(ip, IPVERSION);
ip->ip_tos = 0;
ip->ip_off = 0;
ip->ip_ttl = 60;
@@ -1269,7 +1280,7 @@ int ptest;
u->uh_dport = htons(9);
u->uh_sum = 0;
- nfd = initdevice(dev, u->uh_sport, 1);
+ nfd = initdevice(dev, 1);
u->uh_ulen = htons(7168);
printf("6. Exhaustive mbuf test.\n");
@@ -1280,7 +1291,7 @@ int ptest;
* First send the entire packet in 768 byte chunks.
*/
ip->ip_len = sizeof(*ip) + 768 + sizeof(*u);
- ip->ip_hl = sizeof(*ip) >> 2;
+ IP_HL_A(ip, sizeof(*ip) >> 2);
ip->ip_off = htons(IP_MF);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, 0);
@@ -1298,7 +1309,7 @@ int ptest;
for (j = 768; j < 3584; j += 768) {
ip->ip_len = sizeof(*ip) + 768;
- ip->ip_off = htons(IP_MF|((j>>3) & 0x1fff));
+ ip->ip_off = htons(IP_MF|(j>>3));
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, j);
fflush(stdout);
@@ -1306,7 +1317,7 @@ int ptest;
ip->ip_len = sizeof(*ip) + 128;
for (k = j - 768; k < j; k += 128) {
- ip->ip_off = htons(IP_MF|((k>>3) & 0x1fff));
+ ip->ip_off = htons(IP_MF|(k>>3));
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, k);
fflush(stdout);
@@ -1329,16 +1340,16 @@ ip_t *ip;
struct in_addr gwip;
int ptest;
{
-#ifdef USE_NANOSLEEP
+ ip_t *pip;
+#ifdef USE_NANOSLEEP
struct timespec ts;
#else
struct timeval tv;
#endif
- ip_t *pip;
int nfd, i, j;
u_char *s;
- nfd = initdevice(dev, 0, 1);
+ nfd = initdevice(dev, 1);
pip = (ip_t *)tbuf;
srand(time(NULL) ^ (getpid() * getppid()));
@@ -1348,7 +1359,7 @@ int ptest;
for (i = 0; i < 512; i++) {
for (s = (u_char *)pip, j = 0; j < sizeof(tbuf); j++, s++)
*s = (rand() >> 13) & 0xff;
- pip->ip_v = IPVERSION;
+ IP_V_A(pip, IPVERSION);
bcopy((char *)&ip->ip_dst, (char *)&pip->ip_dst,
sizeof(struct in_addr));
pip->ip_sum = 0;
@@ -1363,7 +1374,7 @@ int ptest;
for (i = 0; i < 512; i++) {
for (s = (u_char *)pip, j = 0; j < sizeof(tbuf); j++, s++)
*s = (rand() >> 13) & 0xff;
- pip->ip_v = IPVERSION;
+ IP_V_A(pip, IPVERSION);
pip->ip_off &= htons(0xc000);
bcopy((char *)&ip->ip_dst, (char *)&pip->ip_dst,
sizeof(struct in_addr));
diff --git a/contrib/ipfilter/ipsend/larp.c b/contrib/ipfilter/ipsend/larp.c
index d178d64..a8e782e 100644
--- a/contrib/ipfilter/ipsend/larp.c
+++ b/contrib/ipfilter/ipsend/larp.c
@@ -1,21 +1,25 @@
+/* $NetBSD$ */
+
/*
* larp.c (C) 1995-1998 Darren Reed
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
#if !defined(lint)
static const char sccsid[] = "@(#)larp.c 1.1 8/19/95 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: larp.c,v 2.1.4.1 2001/06/26 10:43:22 darrenr Exp $";
+static const char rcsid[] = "@(#)Id: larp.c,v 2.4 2003/12/01 02:01:16 darrenr Exp";
#endif
-#include <stdio.h>
-#include <errno.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include <netdb.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <errno.h>
#include "ip_compat.h"
#include "iplang/iplang.h"
@@ -25,7 +29,7 @@ static const char rcsid[] = "@(#)$Id: larp.c,v 2.1.4.1 2001/06/26 10:43:22 darre
* its IP address in address
* (4 bytes)
*/
-int resolve(host, address)
+int resolve(host, address)
char *host, *address;
{
struct hostent *hp;
diff --git a/contrib/ipfilter/ipsend/linux.h b/contrib/ipfilter/ipsend/linux.h
index 2d2a243..d8296ba 100644
--- a/contrib/ipfilter/ipsend/linux.h
+++ b/contrib/ipfilter/ipsend/linux.h
@@ -1,7 +1,11 @@
+/* $NetBSD$ */
+
/*
* Copyright (C) 1995-1998 by Darren Reed.
*
- * See the IPFILTER.LICENCE file for details on licencing.
+ * This code may be freely distributed as long as it retains this notice
+ * and is not changed in any way. The author accepts no responsibility
+ * for the use of this software. I hate legaleese, don't you ?
*
* @(#)linux.h 1.1 8/19/95
*/
diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c
index 23a7621..abe664e 100644
--- a/contrib/ipfilter/ipsend/lsock.c
+++ b/contrib/ipfilter/ipsend/lsock.c
@@ -1,14 +1,14 @@
+/* $NetBSD$ */
+
/*
* lsock.c (C) 1995-1998 Darren Reed
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
#if !defined(lint)
static const char sccsid[] = "@(#)lsock.c 1.2 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: lsock.c,v 2.1.4.3 2002/12/06 11:40:36 darrenr Exp $";
-#endif
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+static const char rcsid[] = "@(#)Id: lsock.c,v 2.3 2001/06/09 17:09:26 darrenr Exp";
#endif
#include <stdio.h>
#include <unistd.h>
@@ -226,7 +226,7 @@ struct in_addr gwip;
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
ti->ti_sport = lsin.sin_port;
printf("sport %d\n", ntohs(lsin.sin_port));
- nfd = initdevice(dev, ntohs(lsin.sin_port), 0);
+ nfd = initdevice(dev, 0);
if (!(s = find_tcp(fd, ti)))
return -1;
diff --git a/contrib/ipfilter/ipsend/resend.c b/contrib/ipfilter/ipsend/resend.c
index 646da1a..07220df 100644
--- a/contrib/ipfilter/ipsend/resend.c
+++ b/contrib/ipfilter/ipsend/resend.c
@@ -1,21 +1,16 @@
+/* $NetBSD$ */
+
/*
* resend.c (C) 1995-1998 Darren Reed
*
- * This was written to test what size TCP fragments would get through
- * various TCP/IP packet filters, as used in IP firewalls. In certain
- * conditions, enough of the TCP header is missing for unpredictable
- * results unless the filter is aware that this can happen.
- *
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: resend.c,v 2.8 2004/01/08 13:34:31 darrenr Exp";
#endif
-#include <stdio.h>
-#include <netdb.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
@@ -24,9 +19,6 @@
#include <arpa/inet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
#ifndef linux
# include <netinet/ip_var.h>
# include <netinet/if_ether.h>
@@ -34,14 +26,13 @@
# include <net/if_var.h>
# endif
#endif
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: resend.c,v 2.1.4.5 2002/12/06 11:40:36 darrenr Exp $";
-#endif
-
-
extern int opts;
static u_char pbuf[65536]; /* 1 big packet */
@@ -54,7 +45,7 @@ ip_t *ip;
tcphdr_t *t;
int i, j;
- t = (tcphdr_t *)((char *)ip + (ip->ip_hl << 2));
+ t = (tcphdr_t *)((char *)ip + (IP_HL(ip) << 2));
if (ip->ip_tos)
printf("tos %#x ", ip->ip_tos);
if (ip->ip_off & 0x3fff)
@@ -88,13 +79,13 @@ char *datain;
ether_header_t *eh;
char dhost[6];
ip_t *ip;
- int fd, wfd = initdevice(dev, 0, 5), len, i;
+ int fd, wfd = initdevice(dev, 5), len, i;
if (datain)
fd = (*r->r_open)(datain);
else
fd = (*r->r_open)("-");
-
+
if (fd < 0)
exit(-1);
@@ -130,7 +121,7 @@ char *datain;
sizeof(dhost));
if (!ip->ip_sum)
ip->ip_sum = chksum((u_short *)ip,
- ip->ip_hl << 2);
+ IP_HL(ip) << 2);
bcopy(ip, (char *)(eh + 1), len);
len += sizeof(*eh);
printpacket(ip);
diff --git a/contrib/ipfilter/ipsend/sbpf.c b/contrib/ipfilter/ipsend/sbpf.c
index ec95b49..9147929 100644
--- a/contrib/ipfilter/ipsend/sbpf.c
+++ b/contrib/ipfilter/ipsend/sbpf.c
@@ -1,18 +1,13 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1995-1998 Darren Reed. (from tcplog)
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#include <stdio.h>
-#include <netdb.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/types.h>
#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mbuf.h>
#include <sys/time.h>
#include <sys/timeb.h>
@@ -37,11 +32,21 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
+
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <signal.h>
+#include <errno.h>
+
#include "ipsend.h"
#if !defined(lint)
static const char sccsid[] = "@(#)sbpf.c 1.3 8/25/95 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: sbpf.c,v 2.1.4.2 2001/09/30 04:04:28 darrenr Exp $";
+static const char rcsid[] = "@(#)Id: sbpf.c,v 2.5 2002/02/24 07:30:03 darrenr Exp";
#endif
/*
@@ -51,17 +56,15 @@ static u_char *buf = NULL;
static int bufsize = 0, timeout = 1;
-int initdevice(device, sport, tout)
+int initdevice(device, tout)
char *device;
-int sport, tout;
+int tout;
{
struct bpf_version bv;
struct timeval to;
struct ifreq ifr;
char bpfname[16];
- int fd, i;
-
- fd = -1;
+ int fd = 0, i;
for (i = 0; i < 16; i++)
{
diff --git a/contrib/ipfilter/ipsend/sdlpi.c b/contrib/ipfilter/ipsend/sdlpi.c
index dcd8422..215223a 100644
--- a/contrib/ipfilter/ipsend/sdlpi.c
+++ b/contrib/ipfilter/ipsend/sdlpi.c
@@ -1,7 +1,10 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1992-1998 Darren Reed. (from tcplog)
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
#include <stdio.h>
@@ -19,10 +22,17 @@
#include <sys/stropts.h>
#ifdef sun
-#include <sys/pfmod.h>
-#include <sys/bufmod.h>
+# include <sys/pfmod.h>
+# include <sys/bufmod.h>
+#endif
+#ifdef __osf__
+# include <sys/dlpihdr.h>
+#else
+# include <sys/dlpi.h>
+#endif
+#ifdef __hpux
+# include <sys/dlpi_ext.h>
#endif
-#include <sys/dlpi.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -38,7 +48,7 @@
#if !defined(lint)
static const char sccsid[] = "@(#)sdlpi.c 1.3 10/30/95 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: sdlpi.c,v 2.1.4.2 2001/06/26 10:43:22 darrenr Exp $";
+static const char rcsid[] = "@(#)Id: sdlpi.c,v 2.8.2.1 2004/12/09 19:41:13 darrenr Exp";
#endif
#define CHUNKSIZE 8192
@@ -49,9 +59,9 @@ static const char rcsid[] = "@(#)$Id: sdlpi.c,v 2.1.4.2 2001/06/26 10:43:22 darr
* Be careful to only include those defined in the flags option for the
* interface are included in the header size.
*/
-int initdevice(device, sport, tout)
+int initdevice(device, tout)
char *device;
-int sport, tout;
+int tout;
{
char devname[16], *s, buf[256];
int i, fd;
@@ -60,7 +70,7 @@ int sport, tout;
(void) strncat(devname, device, sizeof(devname) - strlen(devname));
s = devname + 5;
- while (*s && !isdigit(*s))
+ while (*s && !ISDIGIT(*s))
s++;
if (!*s)
{
@@ -79,24 +89,43 @@ int sport, tout;
exit(-1);
}
- if (dlattachreq(fd, i) == -1 || dlokack(fd, buf) == -1)
+ if (dlattachreq(fd, i) == -1)
+ {
+ fprintf(stderr, "dlattachreq: DLPI error\n");
+ exit(-1);
+ }
+ else if (dlokack(fd, buf) == -1)
+ {
+ fprintf(stderr, "dlokack(attach): DLPI error\n");
+ exit(-1);
+ }
+#ifdef DL_HP_RAWDLS
+ if (dlpromisconreq(fd, DL_PROMISC_SAP) < 0)
{
- fprintf(stderr, "DLPI error\n");
+ fprintf(stderr, "dlpromisconreq: DL_PROMISC_PHYS error\n");
exit(-1);
}
+ else if (dlokack(fd, buf) < 0)
+ {
+ fprintf(stderr, "dlokack(promisc): DLPI error\n");
+ exit(-1);
+ }
+ /* 22 is INSAP as per the HP-UX DLPI Programmer's Guide */
+
+ dlbindreq(fd, 22, 1, DL_HP_RAWDLS, 0, 0);
+#else
dlbindreq(fd, ETHERTYPE_IP, 0, DL_CLDLS, 0, 0);
+#endif
dlbindack(fd, buf);
/*
* write full headers
*/
-#ifdef sun /* we require RAW DLPI mode, which is a Sun extension */
+#ifdef DLIOCRAW /* we require RAW DLPI mode, which is a Sun extension */
if (strioctl(fd, DLIOCRAW, -1, 0, NULL) == -1)
{
fprintf(stderr, "DLIOCRAW error\n");
exit(-1);
}
-#else
-you lose
#endif
return fd;
}
@@ -109,8 +138,19 @@ int sendip(fd, pkt, len)
int fd, len;
char *pkt;
{
- struct strbuf dbuf, *dp = &dbuf;
+ struct strbuf dbuf, *dp = &dbuf, *cp = NULL;
+ int pri = 0;
+#ifdef DL_HP_RAWDLS
+ struct strbuf cbuf;
+ dl_hp_rawdata_req_t raw;
+ cp = &cbuf;
+ raw.dl_primitive = DL_HP_RAWDATA_REQ;
+ cp->len = sizeof(raw);
+ cp->buf = (char *)&raw;
+ cp->maxlen = cp->len;
+ pri = MSG_HIPRI;
+#endif
/*
* construct NIT STREAMS messages, first control then data.
*/
@@ -118,7 +158,7 @@ char *pkt;
dp->len = len;
dp->maxlen = dp->len;
- if (putmsg(fd, NULL, dp, 0) == -1)
+ if (putmsg(fd, cp, dp, pri) == -1)
{
perror("putmsg");
return -1;
@@ -130,3 +170,4 @@ char *pkt;
}
return len;
}
+
diff --git a/contrib/ipfilter/ipsend/sirix.c b/contrib/ipfilter/ipsend/sirix.c
index 8f491f7..39a0992 100644
--- a/contrib/ipfilter/ipsend/sirix.c
+++ b/contrib/ipfilter/ipsend/sirix.c
@@ -1,12 +1,12 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1992-1998 Darren Reed.
* (C)opyright 1997 Marc Boucher.
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
-#endif
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
@@ -23,17 +23,15 @@
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/tcp.h>
#include "ipsend.h"
+#include <netinet/udp_var.h>
#if !defined(lint) && defined(LIBC_SCCS)
static char sirix[] = "@(#)sirix.c 1.0 10/9/97 (C)1997 Marc Boucher";
#endif
-int initdevice(char *device, int sport, int tout)
+int initdevice(char *device, int tout)
{
int fd;
struct sockaddr_raw sr;
diff --git a/contrib/ipfilter/ipsend/slinux.c b/contrib/ipfilter/ipsend/slinux.c
index 7438d1c..3bc7f09 100644
--- a/contrib/ipfilter/ipsend/slinux.c
+++ b/contrib/ipfilter/ipsend/slinux.c
@@ -1,7 +1,10 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1992-1998 Darren Reed. (from tcplog)
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
#include <stdio.h>
@@ -27,7 +30,7 @@
#if !defined(lint)
static const char sccsid[] = "@(#)slinux.c 1.2 8/25/95";
-static const char rcsid[] = "@(#)$Id: slinux.c,v 2.1.4.1 2001/06/26 10:43:22 darrenr Exp $";
+static const char rcsid[] = "@(#)Id: slinux.c,v 2.3 2001/06/09 17:09:26 darrenr Exp";
#endif
#define CHUNKSIZE 8192
@@ -42,9 +45,9 @@ static int timeout;
static char *eth_dev = NULL;
-int initdevice(dev, sport, spare)
+int initdevice(dev, spare)
char *dev;
-int sport, spare;
+int spare;
{
int fd;
diff --git a/contrib/ipfilter/ipsend/snit.c b/contrib/ipfilter/ipsend/snit.c
index 6f2c662..a4b19b9 100644
--- a/contrib/ipfilter/ipsend/snit.c
+++ b/contrib/ipfilter/ipsend/snit.c
@@ -1,7 +1,10 @@
+/* $NetBSD$ */
+
/*
* (C)opyright 1992-1998 Darren Reed. (from tcplog)
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
#include <stdio.h>
@@ -38,7 +41,7 @@
#if !defined(lint)
static const char sccsid[] = "@(#)snit.c 1.5 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: snit.c,v 2.1.4.1 2001/06/26 10:43:22 darrenr Exp $";
+static const char rcsid[] = "@(#)Id: snit.c,v 2.3 2001/06/09 17:09:26 darrenr Exp";
#endif
#define CHUNKSIZE 8192
@@ -54,9 +57,9 @@ static const char rcsid[] = "@(#)$Id: snit.c,v 2.1.4.1 2001/06/26 10:43:22 darre
static int timeout;
-int initdevice(device, sport, tout)
+int initdevice(device, tout)
char *device;
-int sport, tout;
+int tout;
{
struct strioctl si;
struct timeval to;
diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c
index 2e7a11c..ccc57f0 100644
--- a/contrib/ipfilter/ipsend/sock.c
+++ b/contrib/ipfilter/ipsend/sock.c
@@ -1,20 +1,18 @@
+/* $NetBSD$ */
+
/*
* sock.c (C) 1995-1998 Darren Reed
*
* See the IPFILTER.LICENCE file for details on licencing.
+ *
*/
-#if defined(__sgi) && (IRIX > 602)
-# include <sys/ptimers.h>
+#if !defined(lint)
+static const char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
+static const char rcsid[] = "@(#)Id: sock.c,v 2.8.4.1 2004/03/23 12:58:06 darrenr Exp";
#endif
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <pwd.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/param.h>
#include <sys/stat.h>
#ifndef ultrix
#include <fcntl.h>
@@ -24,21 +22,23 @@
#else
# include <sys/dir.h>
#endif
-#define _KERNEL
-#define KERNEL
-#ifdef ultrix
-# undef LOCORE
-# include <sys/smp_lock.h>
+#if !defined(__osf__)
+# define _KERNEL
+# define KERNEL
+# ifdef ultrix
+# undef LOCORE
+# include <sys/smp_lock.h>
+# endif
+# include <sys/file.h>
+# undef _KERNEL
+# undef KERNEL
#endif
-#include <sys/file.h>
-#undef _KERNEL
-#undef KERNEL
#include <nlist.h>
#include <sys/user.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/proc.h>
-#if !defined(ultrix) && !defined(hpux)
+#if !defined(ultrix) && !defined(hpux) && !defined(__osf__)
# include <kvm.h>
#endif
#ifdef sun
@@ -56,18 +56,22 @@
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <net/if.h>
+#if defined(__FreeBSD__)
+# include "radix_ipf.h"
+#endif
#include <net/route.h>
#include <netinet/ip_var.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <pwd.h>
#include "ipsend.h"
-#if !defined(lint)
-static const char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: sock.c,v 2.1.4.6 2002/12/06 11:40:36 darrenr Exp $";
-#endif
-
int nproc;
struct proc *proc;
@@ -379,7 +383,7 @@ struct in_addr gwip;
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
ti->ti_sport = lsin.sin_port;
printf("sport %d\n", ntohs(lsin.sin_port));
- nfd = initdevice(dev, ntohs(lsin.sin_port), 1);
+ nfd = initdevice(dev, 1);
if (!(t = find_tcp(fd, ti)))
return -1;
diff --git a/contrib/ipfilter/ipsend/sockraw.c b/contrib/ipfilter/ipsend/sockraw.c
new file mode 100644
index 0000000..822c146
--- /dev/null
+++ b/contrib/ipfilter/ipsend/sockraw.c
@@ -0,0 +1,89 @@
+/* $NetBSD$ */
+
+/*
+ * (C)opyright 2000 Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * WARNING: Attempting to use this .c file on HP-UX 11.00 will cause the
+ * system to crash.
+ */
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "ipsend.h"
+
+#if !defined(lint) && defined(LIBC_SCCS)
+static char sirix[] = "@(#)sirix.c 1.0 10/9/97 (C)1997 Marc Boucher";
+#endif
+
+
+int initdevice(char *device, int tout)
+{
+ struct sockaddr s;
+ struct ifreq ifr;
+ int fd;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, device, sizeof ifr.ifr_name);
+
+ if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
+ {
+ perror("socket(AF_INET, SOCK_RAW, IPPROTO_RAW)");
+ return -1;
+ }
+
+ if (ioctl(fd, SIOCGIFADDR, &ifr) == -1)
+ {
+ perror("ioctl SIOCGIFADDR");
+ return -1;
+ }
+
+ bzero((char *)&s, sizeof(s));
+ s.sa_family = AF_INET;
+ bcopy(&ifr.ifr_addr, s.sa_data, 4);
+ if (bind(fd, &s, sizeof(s)) == -1)
+ perror("bind");
+ return fd;
+}
+
+
+/*
+ * output an IP packet
+ */
+int sendip(int fd, char *pkt, int len)
+{
+ struct ether_header *eh;
+ struct sockaddr_in sin;
+
+ eh = (struct ether_header *)pkt;
+ bzero((char *)&sin, sizeof(sin));
+ sin.sin_family = AF_INET;
+ pkt += 14;
+ len -= 14;
+ bcopy(pkt + 12, (char *)&sin.sin_addr, 4);
+
+ if (sendto(fd, pkt, len, 0, &sin, sizeof(sin)) == -1)
+ {
+ perror("send");
+ return -1;
+ }
+
+ return len;
+}
diff --git a/contrib/ipfilter/ipsend/tcpip.h b/contrib/ipfilter/ipsend/tcpip.h
index c735593..0d3e040 100644
--- a/contrib/ipfilter/ipsend/tcpip.h
+++ b/contrib/ipfilter/ipsend/tcpip.h
@@ -1,3 +1,5 @@
+/* $NetBSD$ */
+
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -10,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,7 +29,7 @@
* SUCH DAMAGE.
*
* @(#)tcpip.h 8.1 (Berkeley) 6/10/93
- * $Id: tcpip.h,v 2.1 1999/08/04 17:31:16 darrenr Exp $
+ * Id: tcpip.h,v 2.2.2.3 2004/05/26 15:45:48 darrenr Exp
*/
#ifndef _NETINET_TCPIP_H_
@@ -54,12 +52,9 @@ struct ipovly {
*/
struct tcpiphdr {
struct ipovly ti_i; /* overlaid ip structure */
-#ifdef linux
- tcphdr_t ti_t;
-#else
struct tcphdr ti_t; /* tcp header */
-#endif
};
+
#ifdef notyet
/*
* Tcp+ip header, after ip options removed but including TCP options.
OpenPOWER on IntegriCloud