diff options
author | darrenr <darrenr@FreeBSD.org> | 2005-04-25 18:20:15 +0000 |
---|---|---|
committer | darrenr <darrenr@FreeBSD.org> | 2005-04-25 18:20:15 +0000 |
commit | d643bc9db0177adb3aff13bcffd595bcd5417bf2 (patch) | |
tree | 8e099ceb5542b50acce35f82fca9a4168815c6ae /contrib/ipfilter/ipsend | |
parent | f9c93115b7330831536223046595f7f3e5215be5 (diff) | |
download | FreeBSD-src-d643bc9db0177adb3aff13bcffd595bcd5417bf2.zip FreeBSD-src-d643bc9db0177adb3aff13bcffd595bcd5417bf2.tar.gz |
* Someone imported a lot of files with the wrong CVS tag, so lots of files need
that fixed in them....
* Keep unnecessary files out of the non-vendor part of this CVS repository.
Diffstat (limited to 'contrib/ipfilter/ipsend')
32 files changed, 221 insertions, 315 deletions
diff --git a/contrib/ipfilter/ipsend/.OLD/ip_compat.h b/contrib/ipfilter/ipsend/.OLD/ip_compat.h index 3b62be1..b5b8f07 100644 --- a/contrib/ipfilter/ipsend/.OLD/ip_compat.h +++ b/contrib/ipfilter/ipsend/.OLD/ip_compat.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1995 by Darren Reed. diff --git a/contrib/ipfilter/ipsend/44arp.c b/contrib/ipfilter/ipsend/44arp.c index 4206355..1063d3a 100644 --- a/contrib/ipfilter/ipsend/44arp.c +++ b/contrib/ipfilter/ipsend/44arp.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Based upon 4.4BSD's /usr/sbin/arp diff --git a/contrib/ipfilter/ipsend/arp.c b/contrib/ipfilter/ipsend/arp.c index 0e8f556..f90fc3c 100644 --- a/contrib/ipfilter/ipsend/arp.c +++ b/contrib/ipfilter/ipsend/arp.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * arp.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/dlcommon.c b/contrib/ipfilter/ipsend/dlcommon.c index 6e351f0..c6b6e8a 100644 --- a/contrib/ipfilter/ipsend/dlcommon.c +++ b/contrib/ipfilter/ipsend/dlcommon.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Common (shared) DLPI test routines. diff --git a/contrib/ipfilter/ipsend/dltest.h b/contrib/ipfilter/ipsend/dltest.h index 9fafd91..086782c 100644 --- a/contrib/ipfilter/ipsend/dltest.h +++ b/contrib/ipfilter/ipsend/dltest.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Common DLPI Test Suite header file diff --git a/contrib/ipfilter/ipsend/hpux.c b/contrib/ipfilter/ipsend/hpux.c index 69f962c..9cc7299 100644 --- a/contrib/ipfilter/ipsend/hpux.c +++ b/contrib/ipfilter/ipsend/hpux.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1997-1998 Darren Reed. (from tcplog) diff --git a/contrib/ipfilter/ipsend/in_var.h b/contrib/ipfilter/ipsend/in_var.h index f228bbb..3523f77 100644 --- a/contrib/ipfilter/ipsend/in_var.h +++ b/contrib/ipfilter/ipsend/in_var.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* @(#)in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86 */ diff --git a/contrib/ipfilter/ipsend/ip.c b/contrib/ipfilter/ipsend/ip.c index 8302806..cc9f6b9 100644 --- a/contrib/ipfilter/ipsend/ip.c +++ b/contrib/ipfilter/ipsend/ip.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * ip.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/ip_var.h b/contrib/ipfilter/ipsend/ip_var.h index b08f4e7..ab9813e 100644 --- a/contrib/ipfilter/ipsend/ip_var.h +++ b/contrib/ipfilter/ipsend/ip_var.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* @(#)ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86 */ diff --git a/contrib/ipfilter/ipsend/ipresend.1 b/contrib/ipfilter/ipsend/ipresend.1 index cffc6f3..6761a18 100644 --- a/contrib/ipfilter/ipsend/ipresend.1 +++ b/contrib/ipfilter/ipsend/ipresend.1 @@ -1,4 +1,4 @@ -.\" $NetBSD$ +.\" $FreeBSD$ .\" .TH IPRESEND 1 .SH NAME diff --git a/contrib/ipfilter/ipsend/ipresend.c b/contrib/ipfilter/ipsend/ipresend.c index 1db54e1..3a11d83 100644 --- a/contrib/ipfilter/ipsend/ipresend.c +++ b/contrib/ipfilter/ipsend/ipresend.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * ipresend.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/ipsend.1 b/contrib/ipfilter/ipsend/ipsend.1 index 33320f3..7f0a8e3 100644 --- a/contrib/ipfilter/ipsend/ipsend.1 +++ b/contrib/ipfilter/ipsend/ipsend.1 @@ -1,4 +1,4 @@ -.\" $NetBSD$ +.\" $FreeBSD$ .\" .TH IPSEND 1 .SH NAME diff --git a/contrib/ipfilter/ipsend/ipsend.5 b/contrib/ipfilter/ipsend/ipsend.5 index 40b186a..cd5842c 100644 --- a/contrib/ipfilter/ipsend/ipsend.5 +++ b/contrib/ipfilter/ipsend/ipsend.5 @@ -359,7 +359,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 80faef2..06be711 100644 --- a/contrib/ipfilter/ipsend/ipsend.c +++ b/contrib/ipfilter/ipsend/ipsend.c @@ -2,21 +2,12 @@ /* * 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> @@ -24,21 +15,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.3 2001/07/15 22:00:14 darrenr Exp $"; */ -static const char rcsid[] = "@(#)$FreeBSD$"; +#include "ipf.h" +#ifndef linux +# include <netinet/udp_var.h> #endif @@ -48,27 +37,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 *)); @@ -163,13 +152,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); } @@ -187,7 +172,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; @@ -210,8 +195,6 @@ int argc; char **argv; { FILE *langfile = NULL; - struct tcpiphdr *ti; - struct udpiphdr *ui; struct in_addr gwip; tcphdr_t *tcp; udphdr_t *udp; @@ -225,15 +208,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' : @@ -327,7 +307,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++; @@ -352,6 +332,7 @@ char **argv; fprintf(stderr, "Unknown option \"%c\"\n", c); usage(name); } + } if (argc - optind < 1) usage(name); @@ -383,11 +364,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; @@ -395,22 +371,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); } } @@ -450,11 +428,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 be98c1b..91cfa6c 100644 --- a/contrib/ipfilter/ipsend/ipsend.h +++ b/contrib/ipfilter/ipsend/ipsend.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * ipsend.h (C) 1997-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/ipsopt.c b/contrib/ipfilter/ipsend/ipsopt.c index 7f16705..a85f162 100644 --- a/contrib/ipfilter/ipsend/ipsopt.c +++ b/contrib/ipfilter/ipsend/ipsopt.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Copyright (C) 1995-1998 by Darren Reed. diff --git a/contrib/ipfilter/ipsend/iptest.1 b/contrib/ipfilter/ipsend/iptest.1 index ca74094..8f25f4a 100644 --- a/contrib/ipfilter/ipsend/iptest.1 +++ b/contrib/ipfilter/ipsend/iptest.1 @@ -1,3 +1,5 @@ +.\" $FreeBSD$ +.\" .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 45f8f3a..0e81ec5 100644 --- a/contrib/ipfilter/ipsend/iptest.c +++ b/contrib/ipfilter/ipsend/iptest.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * ipsend.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/iptests.c b/contrib/ipfilter/ipsend/iptests.c index 4805caf..51715d8 100644 --- a/contrib/ipfilter/ipsend/iptests.c +++ b/contrib/ipfilter/ipsend/iptests.c @@ -1,35 +1,38 @@ +/* $FreeBSD$ */ + /* * 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,39 +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 0 -#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 -__FBSDID("$FreeBSD$"); - -#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 @@ -106,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; @@ -114,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; @@ -128,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)) { /* @@ -137,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); @@ -153,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); @@ -168,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); @@ -186,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); @@ -200,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); @@ -218,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); @@ -237,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); @@ -249,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); @@ -318,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'); @@ -352,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); @@ -362,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); @@ -389,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'); @@ -454,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; @@ -463,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)) { @@ -484,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 @@ -549,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; @@ -557,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)) { /* @@ -745,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; @@ -754,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); @@ -789,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; @@ -807,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); @@ -848,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); @@ -907,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; @@ -915,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); @@ -928,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++) { @@ -1058,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++) { @@ -1134,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); @@ -1150,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; @@ -1254,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; @@ -1262,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; @@ -1273,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"); @@ -1284,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); @@ -1302,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); @@ -1310,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); @@ -1333,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())); @@ -1352,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; @@ -1367,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 a8e782e..1e0b169 100644 --- a/contrib/ipfilter/ipsend/larp.c +++ b/contrib/ipfilter/ipsend/larp.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * larp.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/linux.h b/contrib/ipfilter/ipsend/linux.h index d8296ba..a36d1bf 100644 --- a/contrib/ipfilter/ipsend/linux.h +++ b/contrib/ipfilter/ipsend/linux.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Copyright (C) 1995-1998 by Darren Reed. diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c index abe664e..8c6616d 100644 --- a/contrib/ipfilter/ipsend/lsock.c +++ b/contrib/ipfilter/ipsend/lsock.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * lsock.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/resend.c b/contrib/ipfilter/ipsend/resend.c index 07220df..fb2d8bd 100644 --- a/contrib/ipfilter/ipsend/resend.c +++ b/contrib/ipfilter/ipsend/resend.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * resend.c (C) 1995-1998 Darren Reed diff --git a/contrib/ipfilter/ipsend/sbpf.c b/contrib/ipfilter/ipsend/sbpf.c index 82db7ca..c25a423 100644 --- a/contrib/ipfilter/ipsend/sbpf.c +++ b/contrib/ipfilter/ipsend/sbpf.c @@ -3,17 +3,10 @@ * (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> @@ -38,11 +31,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 /* @@ -52,17 +55,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 215223a..3ff9d4b 100644 --- a/contrib/ipfilter/ipsend/sdlpi.c +++ b/contrib/ipfilter/ipsend/sdlpi.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1992-1998 Darren Reed. (from tcplog) diff --git a/contrib/ipfilter/ipsend/sirix.c b/contrib/ipfilter/ipsend/sirix.c index 39a0992..5057c4f 100644 --- a/contrib/ipfilter/ipsend/sirix.c +++ b/contrib/ipfilter/ipsend/sirix.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1992-1998 Darren Reed. diff --git a/contrib/ipfilter/ipsend/slinux.c b/contrib/ipfilter/ipsend/slinux.c index 3bc7f09..1021acf 100644 --- a/contrib/ipfilter/ipsend/slinux.c +++ b/contrib/ipfilter/ipsend/slinux.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1992-1998 Darren Reed. (from tcplog) diff --git a/contrib/ipfilter/ipsend/snit.c b/contrib/ipfilter/ipsend/snit.c index a4b19b9..b57609b 100644 --- a/contrib/ipfilter/ipsend/snit.c +++ b/contrib/ipfilter/ipsend/snit.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 1992-1998 Darren Reed. (from tcplog) diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c index 988da4c..5020a4a 100644 --- a/contrib/ipfilter/ipsend/sock.c +++ b/contrib/ipfilter/ipsend/sock.c @@ -3,19 +3,15 @@ * 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> @@ -25,21 +21,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 @@ -57,18 +55,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; @@ -381,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 index 822c146..c923227 100644 --- a/contrib/ipfilter/ipsend/sockraw.c +++ b/contrib/ipfilter/ipsend/sockraw.c @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * (C)opyright 2000 Darren Reed. diff --git a/contrib/ipfilter/ipsend/tcpip.h b/contrib/ipfilter/ipsend/tcpip.h index 0d3e040..c609434 100644 --- a/contrib/ipfilter/ipsend/tcpip.h +++ b/contrib/ipfilter/ipsend/tcpip.h @@ -1,4 +1,4 @@ -/* $NetBSD$ */ +/* $FreeBSD$ */ /* * Copyright (c) 1982, 1986, 1993 diff --git a/contrib/ipfilter/ipsend/ultrix.c b/contrib/ipfilter/ipsend/ultrix.c deleted file mode 100644 index f41a8a9..0000000 --- a/contrib/ipfilter/ipsend/ultrix.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * (C)opyright 1998 Darren Reed. (from tcplog) - * - * See the IPFILTER.LICENCE file for details on licencing. - */ -#include <stdio.h> -#include <strings.h> -#include <unistd.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/if_ether.h> -#include <netdnet/dli_var.h> - - -static struct dli_devid dli_devid; - - -int initdevice(device, sport, tout) -char *device; -int sport, tout; -{ - u_char *s; - int fd; - - fd = socket(AF_DLI, SOCK_DGRAM, 0); - if (fd == -1) - perror("socket(AF_DLI,SOCK_DGRAM)"); - else { - strncpy(dli_devid.dli_devname, device, DLI_DEVSIZE); - dli_devid.dli_devname[DLI_DEVSIZE] ='\0'; - for (s = dli_devid.dli_devname; *s && isalpha((char)*s); s++) - ; - if (*s && isdigit((char)*s)) { - dli_devid.dli_devnumber = atoi(s); - } - } - return fd; -} - - -/* - * output an IP packet onto a fd opened for /dev/bpf - */ -int sendip(fd, pkt, len) -int fd, len; -char *pkt; -{ - struct sockaddr_dl dl; - struct sockaddr_edl *edl = &dl.choose_addr.dli_eaddr; - - dl.dli_family = AF_DLI; - dl.dli_substructype = DLI_ETHERNET; - bcopy((char *)&dli_devid, (char *)&dl.dli_device, sizeof(dli_devid)); - bcopy(pkt, edl->dli_target, DLI_EADDRSIZE); - bcopy(pkt, edl->dli_dest, DLI_EADDRSIZE); - bcopy(pkt + DLI_EADDRSIZE * 2, (char *)&edl->dli_protype, 2); - edl->dli_ioctlflg = 0; - - if (sendto(fd, pkt, len, 0, (struct sockaddr *)&dl, sizeof(dl)) == -1) - { - perror("send"); - return -1; - } - - return len; -} - - -char *strdup(str) -char *str; -{ - char *s; - - if ((s = (char *)malloc(strlen(str) + 1))) - return strcpy(s, str); - return NULL; -} |