diff options
author | guido <guido@FreeBSD.org> | 2006-08-16 12:23:02 +0000 |
---|---|---|
committer | guido <guido@FreeBSD.org> | 2006-08-16 12:23:02 +0000 |
commit | e49049679f4ee5ce6bb9214122154c529a811b5e (patch) | |
tree | 435ea094ad0e55736442383de5885c9c40c9d2a2 /contrib/ipfilter/ipsend | |
parent | fcfb8e57499dfda26645e92a1b5ad74c6f35ee92 (diff) | |
download | FreeBSD-src-e49049679f4ee5ce6bb9214122154c529a811b5e.zip FreeBSD-src-e49049679f4ee5ce6bb9214122154c529a811b5e.tar.gz |
Resolve conflicts
MFC after: 1 weeks
Diffstat (limited to 'contrib/ipfilter/ipsend')
-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 | 45 |
6 files changed, 95 insertions, 14 deletions
diff --git a/contrib/ipfilter/ipsend/ipsend.c b/contrib/ipfilter/ipsend/ipsend.c index 9994db8..06191ec 100644 --- a/contrib/ipfilter/ipsend/ipsend.c +++ b/contrib/ipfilter/ipsend/ipsend.c @@ -6,7 +6,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> @@ -155,6 +155,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 90cbd62..ea358df 100644 --- a/contrib/ipfilter/ipsend/iptests.c +++ b/contrib/ipfilter/ipsend/iptests.c @@ -8,10 +8,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 @@ -136,7 +144,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)) { /* @@ -470,11 +481,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)) { @@ -574,7 +588,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)) { /* @@ -773,7 +790,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)) { /* @@ -936,7 +956,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)) { /* @@ -1281,6 +1304,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"); @@ -1350,6 +1376,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 27cc37e..a76bbbb 100644 --- a/contrib/ipfilter/ipsend/lsock.c +++ b/contrib/ipfilter/ipsend/lsock.c @@ -8,7 +8,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> @@ -227,6 +227,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 9290693..da5c2bf 100644 --- a/contrib/ipfilter/ipsend/resend.c +++ b/contrib/ipfilter/ipsend/resend.c @@ -8,7 +8,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> @@ -81,6 +81,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 @@ -101,6 +104,7 @@ char *datain; if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1)) { perror("arp"); + free(eh); return -2; } @@ -137,5 +141,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 78b75b3..b8778c6 100644 --- a/contrib/ipfilter/ipsend/sbpf.c +++ b/contrib/ipfilter/ipsend/sbpf.c @@ -37,6 +37,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> @@ -45,7 +48,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 /* @@ -62,6 +65,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; @@ -76,6 +89,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 8c7bfcc..f6edbd2 100644 --- a/contrib/ipfilter/ipsend/sock.c +++ b/contrib/ipfilter/ipsend/sock.c @@ -7,12 +7,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 @@ -302,28 +310,33 @@ 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)); if (KMCPY(s, f->f_data, sizeof(*s)) == -1) { fprintf(stderr, "read(%#lx,%#lx,%lu) - f_data - failed\n", - (u_long)f->f_data, (u_long)s, - (u_long)sizeof(*s)); - return NULL; + (u_long)f->f_data, (u_long)s, (u_long)sizeof(*s)); + goto finderror; } i = (struct inpcb *)calloc(1, sizeof(*i)); @@ -331,7 +344,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)); @@ -339,9 +352,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 */ @@ -383,7 +409,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; |