diff options
author | guido <guido@FreeBSD.org> | 2006-08-16 11:51:32 +0000 |
---|---|---|
committer | guido <guido@FreeBSD.org> | 2006-08-16 11:51:32 +0000 |
commit | 092f5d1218f4867a87b382d75613b9d2b3e56c18 (patch) | |
tree | e49755bc5470450d9acf44918f68b5acd3915e51 /contrib/ipfilter/ipsend | |
parent | 9749beb9e35afd40d054e5592764d50ed069a890 (diff) | |
download | FreeBSD-src-092f5d1218f4867a87b382d75613b9d2b3e56c18.zip FreeBSD-src-092f5d1218f4867a87b382d75613b9d2b3e56c18.tar.gz |
Import IP Filter 4.1.13
Diffstat (limited to 'contrib/ipfilter/ipsend')
-rw-r--r-- | contrib/ipfilter/ipsend/.OLD/ip_compat.h | 2 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/ipsend.c | 4 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/iptests.c | 33 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/lsock.c | 4 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/resend.c | 7 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/sbpf.c | 16 | ||||
-rw-r--r-- | contrib/ipfilter/ipsend/sock.c | 42 |
7 files changed, 94 insertions, 14 deletions
diff --git a/contrib/ipfilter/ipsend/.OLD/ip_compat.h b/contrib/ipfilter/ipsend/.OLD/ip_compat.h index 3b62be1..c38fa59 100644 --- a/contrib/ipfilter/ipsend/.OLD/ip_compat.h +++ b/contrib/ipfilter/ipsend/.OLD/ip_compat.h @@ -1,5 +1,3 @@ -/* $NetBSD$ */ - /* * (C)opyright 1995 by Darren Reed. * diff --git a/contrib/ipfilter/ipsend/ipsend.c b/contrib/ipfilter/ipsend/ipsend.c index a3cc1dc..dcd897c 100644 --- a/contrib/ipfilter/ipsend/ipsend.c +++ b/contrib/ipfilter/ipsend/ipsend.c @@ -5,7 +5,7 @@ */ #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 $"; +static const char rcsid[] = "@(#)$Id: ipsend.c,v 2.8.2.3 2006/03/17 13:45:34 darrenr Exp $"; #endif #include <sys/param.h> #include <sys/types.h> @@ -154,6 +154,8 @@ struct in_addr gwip; int wfd; wfd = initdevice(dev, 5); + if (wfd == -1) + return -1; return send_packet(wfd, mtu, ip, gwip); } diff --git a/contrib/ipfilter/ipsend/iptests.c b/contrib/ipfilter/ipsend/iptests.c index 434b010..9329c22 100644 --- a/contrib/ipfilter/ipsend/iptests.c +++ b/contrib/ipfilter/ipsend/iptests.c @@ -6,10 +6,18 @@ */ #if !defined(lint) static const char sccsid[] = "%W% %G% (C)1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id: iptests.c,v 2.8.2.4 2005/06/12 07:18:39 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: iptests.c,v 2.8.2.7 2006/03/21 16:10:55 darrenr Exp $"; #endif #include <sys/param.h> #include <sys/types.h> +#if defined(__NetBSD__) && defined(__vax__) +/* + * XXX need to declare boolean_t for _KERNEL <sys/files.h> + * which ends up including <sys/device.h> for vax. See PR#32907 + * for further details. + */ +typedef int boolean_t; +#endif #include <sys/time.h> #if !defined(__osf__) # define _KERNEL @@ -134,7 +142,10 @@ 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, 1); + if (nfd == -1) + return; if (!ptest || (ptest == 1)) { /* @@ -468,11 +479,14 @@ int ptest; int nfd; u_char *s; - s = (u_char *)(ip + 1); + nfd = initdevice(dev, 1); + if (nfd == -1) + return; IP_HL_A(ip, 6); ip->ip_len = IP_HL(ip) << 2; + s = (u_char *)(ip + 1); s[IPOPT_OPTVAL] = IPOPT_NOP; s++; if (!ptest || (ptest == 1)) { @@ -572,7 +586,10 @@ int ptest; ip->ip_sum = 0; ip->ip_len = sizeof(*ip) + sizeof(*icp); icp = (struct icmp *)((char *)ip + (IP_HL(ip) << 2)); + nfd = initdevice(dev, 1); + if (nfd == -1) + return; if (!ptest || (ptest == 1)) { /* @@ -771,7 +788,10 @@ int ptest; u->uh_sport = htons(1); u->uh_dport = htons(1); u->uh_ulen = htons(sizeof(*u) + 4); + nfd = initdevice(dev, 1); + if (nfd == -1) + return; if (!ptest || (ptest == 1)) { /* @@ -934,7 +954,10 @@ int ptest; t->th_seq = htonl(1); t->th_ack = 0; ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t); + nfd = initdevice(dev, 1); + if (nfd == -1) + return; if (!ptest || (ptest == 1)) { /* @@ -1279,6 +1302,9 @@ int ptest; u->uh_sum = 0; nfd = initdevice(dev, 1); + if (nfd == -1) + return; + u->uh_ulen = htons(7168); printf("6. Exhaustive mbuf test.\n"); @@ -1348,6 +1374,9 @@ int ptest; u_char *s; nfd = initdevice(dev, 1); + if (nfd == -1) + return; + pip = (ip_t *)tbuf; srand(time(NULL) ^ (getpid() * getppid())); diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c index 825495e..7163ea7 100644 --- a/contrib/ipfilter/ipsend/lsock.c +++ b/contrib/ipfilter/ipsend/lsock.c @@ -6,7 +6,7 @@ */ #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.3 2001/06/09 17:09:26 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: lsock.c,v 2.3.4.1 2006/03/17 13:45:34 darrenr Exp $"; #endif #include <stdio.h> #include <unistd.h> @@ -225,6 +225,8 @@ struct in_addr gwip; ti->ti_sport = lsin.sin_port; printf("sport %d\n", ntohs(lsin.sin_port)); nfd = initdevice(dev, 0); + if (nfd == -1) + return -1; if (!(s = find_tcp(fd, ti))) return -1; diff --git a/contrib/ipfilter/ipsend/resend.c b/contrib/ipfilter/ipsend/resend.c index 9c782ac..b51ba06 100644 --- a/contrib/ipfilter/ipsend/resend.c +++ b/contrib/ipfilter/ipsend/resend.c @@ -6,7 +6,7 @@ */ #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 $"; +static const char rcsid[] = "@(#)$Id: resend.c,v 2.8.2.2 2006/03/17 13:45:34 darrenr Exp $"; #endif #include <sys/param.h> #include <sys/types.h> @@ -79,6 +79,9 @@ char *datain; ip_t *ip; int fd, wfd = initdevice(dev, 5), len, i; + if (wfd == -1) + return -1; + if (datain) fd = (*r->r_open)(datain); else @@ -99,6 +102,7 @@ char *datain; if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1)) { perror("arp"); + free(eh); return -2; } @@ -135,5 +139,6 @@ char *datain; } } (*r->r_close)(); + free(eh); return 0; } diff --git a/contrib/ipfilter/ipsend/sbpf.c b/contrib/ipfilter/ipsend/sbpf.c index 16a6e7f..374b7ed 100644 --- a/contrib/ipfilter/ipsend/sbpf.c +++ b/contrib/ipfilter/ipsend/sbpf.c @@ -36,6 +36,9 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#ifdef __NetBSD__ +# include <paths.h> +#endif #include <ctype.h> #include <signal.h> #include <errno.h> @@ -44,7 +47,7 @@ #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.5 2002/02/24 07:30:03 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: sbpf.c,v 2.5.4.1 2006/03/21 16:32:58 darrenr Exp $"; #endif /* @@ -61,6 +64,16 @@ int tout; struct bpf_version bv; struct timeval to; struct ifreq ifr; +#ifdef _PATH_BPF + char *bpfname = _PATH_BPF; + int fd; + + if ((fd = open(bpfname, O_RDWR)) < 0) + { + fprintf(stderr, "no bpf devices available as /dev/bpfxx\n"); + return -1; + } +#else char bpfname[16]; int fd = 0, i; @@ -75,6 +88,7 @@ int tout; fprintf(stderr, "no bpf devices available as /dev/bpfxx\n"); return -1; } +#endif if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0) { diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c index 45e7a0d..09d808d 100644 --- a/contrib/ipfilter/ipsend/sock.c +++ b/contrib/ipfilter/ipsend/sock.c @@ -6,12 +6,20 @@ */ #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 $"; +static const char rcsid[] = "@(#)$Id: sock.c,v 2.8.4.4 2006/03/21 16:10:56 darrenr Exp $"; #endif #include <sys/param.h> #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> +#if defined(__NetBSD__) && defined(__vax__) +/* + * XXX need to declare boolean_t for _KERNEL <sys/files.h> + * which ends up including <sys/device.h> for vax. See PR#32907 + * for further details. + */ +typedef int boolean_t; +#endif #ifndef ultrix #include <fcntl.h> #endif @@ -301,19 +309,25 @@ struct tcpiphdr *ti; } #endif + o = NULL; + f = NULL; + s = NULL; + i = NULL; + t = NULL; + o = (struct file **)calloc(1, sizeof(*o) * (fd->fd_lastfile + 1)); if (KMCPY(o, fd->fd_ofiles, (fd->fd_lastfile + 1) * sizeof(*o)) == -1) { fprintf(stderr, "read(%#lx,%#lx,%lu) - u_ofile - failed\n", (u_long)fd->fd_ofiles, (u_long)o, (u_long)sizeof(*o)); - return NULL; + goto finderror; } f = (struct file *)calloc(1, sizeof(*f)); if (KMCPY(f, o[tfd], sizeof(*f)) == -1) { fprintf(stderr, "read(%#lx,%#lx,%lu) - o[tfd] - failed\n", (u_long)o[tfd], (u_long)f, (u_long)sizeof(*f)); - return NULL; + goto finderror; } s = (struct socket *)calloc(1, sizeof(*s)); @@ -321,7 +335,7 @@ struct tcpiphdr *ti; { fprintf(stderr, "read(%#lx,%#lx,%lu) - f_data - failed\n", (u_long)f->f_data, (u_long)s, (u_long)sizeof(*s)); - return NULL; + goto finderror; } i = (struct inpcb *)calloc(1, sizeof(*i)); @@ -329,7 +343,7 @@ struct tcpiphdr *ti; { fprintf(stderr, "kvm_read(%#lx,%#lx,%lu) - so_pcb - failed\n", (u_long)s->so_pcb, (u_long)i, (u_long)sizeof(*i)); - return NULL; + goto finderror; } t = (struct tcpcb *)calloc(1, sizeof(*t)); @@ -337,9 +351,22 @@ struct tcpiphdr *ti; { fprintf(stderr, "read(%#lx,%#lx,%lu) - inp_ppcb - failed\n", (u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t)); - return NULL; + goto finderror; } return (struct tcpcb *)i->inp_ppcb; + +finderror: + if (o != NULL) + free(o); + if (f != NULL) + free(f); + if (s != NULL) + free(s); + if (i != NULL) + free(i); + if (t != NULL) + free(t); + return NULL; } #endif /* BSD < 199301 */ @@ -381,7 +408,10 @@ 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, 1); + if (nfd == -1) + return -1; if (!(t = find_tcp(fd, ti))) return -1; |