diff options
Diffstat (limited to 'usr.sbin/ipsend/ipresend')
-rw-r--r-- | usr.sbin/ipsend/ipresend/Makefile | 15 | ||||
-rw-r--r-- | usr.sbin/ipsend/ipresend/ipresend.1 | 119 | ||||
-rw-r--r-- | usr.sbin/ipsend/ipresend/ipresend.c | 168 | ||||
-rw-r--r-- | usr.sbin/ipsend/ipresend/resend.c | 144 |
4 files changed, 0 insertions, 446 deletions
diff --git a/usr.sbin/ipsend/ipresend/Makefile b/usr.sbin/ipsend/ipresend/Makefile deleted file mode 100644 index f75d2ed2c40..00000000000 --- a/usr.sbin/ipsend/ipresend/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# $OpenBSD: Makefile,v 1.4 1999/02/21 23:11:05 tholo Exp $ - -PROG= ipresend -BINDIR= /usr/sbin -MAN= ipresend.1 -SRCS= ipresend.c resend.c \ - ipft_ef.c ipft_hx.c ipft_pc.c ipft_sn.c ipft_td.c ipft_tx.c opt.c \ - sock.c 44arp.c sbpf.c ip.c -CFLAGS+= -DDOSOCKET -I${.CURDIR}/../common -I${.CURDIR}/../../ipftest \ - -I${.CURDIR}/../../../sbin/ipf \ - -I${.CURDIR}/../../../sys/netinet -.PATH: ${.CURDIR}/../common ${.CURDIR}/../../ipftest \ - ${.CURDIR}/../../../sbin/ipf - -.include <bsd.prog.mk> diff --git a/usr.sbin/ipsend/ipresend/ipresend.1 b/usr.sbin/ipsend/ipresend/ipresend.1 deleted file mode 100644 index c380c638d2e..00000000000 --- a/usr.sbin/ipsend/ipresend/ipresend.1 +++ /dev/null @@ -1,119 +0,0 @@ -./" $OpenBSD: ipresend.1,v 1.10 2000/11/09 17:53:15 aaron Exp $ -.Dd October 9, 1999 -.Dt IPRESEND 1 -.Os -.Sh NAME -.Nm ipresend -.Nd resend IP packets out to network -.Sh SYNOPSIS -.Nm ipsend -.Op Fl EHPRSTX -.Op Fl d Ar device -.Op Fl g Ar gateway -.Op Fl m Ar mtu -.Op Fl r Ar filename -.Sh DESCRIPTION -.Nm -was designed to allow captured packets to be resent -onto the network for use in testing. -.Nm -supports a -number of different file formats as input, including saved snoop and -.Xr tcpdump 8 -binary data. -.Pp -.Nm -must be run as root. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl d Ar interface -Set the interface name to be the name supplied. -This is useful with the -.Fl P , -.Fl S , -.Fl T , -and -.Fl E -options, where it is not otherwise possible -to associate a packet with an interface. -Normal -.Sq text packets -can override this setting. -.It Fl g Ar gateway -Specify the hostname of the gateway through which to route packets. -This is required whenever the destination host isn't directly attached to the -same network as the host from which you're sending. -.It Fl m Ar mtu -Set the MTU used when sending out packets to -.Ar mtu . -This option allows you -to set a fake MTU, allowing the simulation of network interfaces with small -MTU's. -.It Fl r Ar filename -Specify the filename from which to take input. -Default is -.Va stdin . -.It Fl E -The input file is to be text output from etherfind. -The text formats which -are currently supported are those which result from the following etherfind -option combinations: -.Bd -literal -offset indent -etherfind -n -etherfind -n -t -.Ed -.It Fl H -The input file is to be hex digits, representing the binary makeup of the -packet. -No length correction is made if an incorrect length is put in -the IP header. -.It Fl P -The input file specified by -.Fl r -is a binary file produced using libpcap -(i.e., -.Xr tcpdump 8 -version 3). -Packets are read from this file as being input (for rule purposes). -.It Fl R -When sending packets out, send them out -.Sq raw -(the way they came in). -The only real significance here is that it will expect the link layer (i.e., -Ethernet) headers to be prepended to the IP packet being output. -.It Fl S -The input file is to be in -.Sq snoop -format (see -.Tn RFC 1761 ) . -Packets are read -from this file and used as input from any interface. -This is perhaps the most useful input type, currently. -.It Fl T -The input file is to be text output from -.Xr tcpdump 8 . -The text formats which -are currently supported are those which result from the following -.Xr tcpdump 8 -option combinations: -.Bd -literal -offset indent -tcpdump -n -tcpdump -nq -tcpdump -nqt -tcpdump -nqtt -tcpdump -nqte -.Ed -.It Fl X -The input file is composed of text descriptions of IP packets. -.El -.Sh SEE ALSO -.Xr ipftest 1 , -.Xr ipresend 1 , -.Xr iptest 1 , -.Xr bpf 4 , -.Xr tcpdump 8 -.Sh BUGS -Not all of the input formats are sufficiently capable of introducing a -wide enough variety of packets for them to be all useful in testing. -If you find any, please send email to me at darrenr@cyber.com.au diff --git a/usr.sbin/ipsend/ipresend/ipresend.c b/usr.sbin/ipsend/ipresend/ipresend.c deleted file mode 100644 index 5a4c4ba4aeb..00000000000 --- a/usr.sbin/ipsend/ipresend/ipresend.c +++ /dev/null @@ -1,168 +0,0 @@ -/* $OpenBSD: ipresend.c,v 1.5 2001/01/17 06:01:25 fgsch Exp $ */ - -/* - * 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. - * - * 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. - */ -#if !defined(lint) -static const char sccsid[] = "%W% %G% (C)1995 Darren Reed"; -static const char rcsid[] = "@(#)$IPFilter: ipresend.c,v 2.1 1999/08/04 17:31:05 darrenr Exp $"; -#endif -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <netdb.h> -#include <string.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 "ipsend.h" - - -extern char *optarg; -extern int optind; -#ifndef NO_IPF -extern struct ipread snoop, pcap, etherf, iphex, tcpd, iptext; -#endif - -int opts = 0; -#ifndef DEFAULT_DEVICE -# ifdef linux -char default_device[] = "eth0"; -# else -# ifdef sun -char default_device[] = "le0"; -# else -# ifdef ultrix -char default_device[] = "ln0"; -# else -# ifdef __bsdi__ -char default_device[] = "ef0"; -# else -# ifdef __sgi -char default_device[] = "ec0"; -# else -char default_device[] = "lan0"; -# endif -# endif -# endif -# endif -# endif -#else -char default_device[] = DEFAULT_DEVICE; -#endif - - -static void usage __P((char *)); -int main __P((int, char **)); - - -static void usage(prog) -char *prog; -{ - fprintf(stderr, "Usage: %s [options] <-r filename|-R filename>\n\ -\t\t-r filename\tsnoop data file to resend\n\ -\t\t-R filename\tlibpcap data file to resend\n\ -\toptions:\n\ -\t\t-d device\tSend out on this device\n\ -\t\t-g gateway\tIP gateway to use if non-local dest.\n\ -\t\t-m mtu\t\tfake MTU to use when sending out\n\ -", prog); - exit(1); -} - - -int main(argc, argv) -int argc; -char **argv; -{ - struct in_addr gwip; - struct ipread *ipr = NULL; - char *name = argv[0], *gateway = NULL, *dev = NULL; - char *resend = NULL; - int mtu = 1500, c; - - while ((c = getopt(argc, argv, "EHPRSTXd:g:m:r:")) != -1) - switch (c) - { - case 'd' : - dev = optarg; - break; - case 'g' : - gateway = optarg; - break; - case 'm' : - mtu = atoi(optarg); - if (mtu < 28) - { - fprintf(stderr, "mtu must be > 28\n"); - exit(1); - } - case 'r' : - resend = optarg; - break; - case 'R' : - opts |= OPT_RAW; - break; -#ifndef NO_IPF - case 'E' : - ipr = ðerf; - break; - case 'H' : - ipr = &iphex; - break; - case 'P' : - ipr = &pcap; - break; - case 'S' : - ipr = &snoop; - break; - case 'T' : - ipr = &tcpd; - break; - case 'X' : - ipr = &iptext; - break; -#endif - default : - fprintf(stderr, "Unknown option \"%c\"\n", c); - usage(name); - } - - if (!ipr || !resend) - usage(name); - - gwip.s_addr = 0; - if (gateway && resolve(gateway, (char *)&gwip) == -1) - { - fprintf(stderr,"Cant resolve %s\n", gateway); - exit(2); - } - - if (!dev) - dev = default_device; - - printf("Device: %s\n", dev); - printf("Gateway: %s\n", inet_ntoa(gwip)); - printf("mtu: %d\n", mtu); - - return ip_resend(dev, mtu, ipr, gwip, resend); -} diff --git a/usr.sbin/ipsend/ipresend/resend.c b/usr.sbin/ipsend/ipresend/resend.c deleted file mode 100644 index 7890062250d..00000000000 --- a/usr.sbin/ipsend/ipresend/resend.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $OpenBSD: resend.c,v 1.4 2001/01/17 06:01:26 fgsch Exp $ */ - -/* - * 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. - * - * 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. - */ -#if !defined(lint) -static const char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed"; -static const char rcsid[] = "@(#)$IPFilter: resend.c,v 2.1 1999/08/04 17:31:12 darrenr Exp $"; -#endif -#include <stdio.h> -#include <netdb.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <net/if.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> -# include <netinet/if_ether.h> -# if __FreeBSD_version >= 300000 -# include <net/if_var.h> -# endif -#endif -#include "ipsend.h" - -extern int opts; - -static u_char pbuf[65536]; /* 1 big packet */ -void printpacket __P((ip_t *)); - - -void printpacket(ip) -ip_t *ip; -{ - tcphdr_t *t; - int i, j; - - t = (tcphdr_t *)((char *)ip + (ip->ip_hl << 2)); - if (ip->ip_tos) - printf("tos %#x ", ip->ip_tos); - if (ip->ip_off & 0x3fff) - printf("frag @%#x ", (ip->ip_off & 0x1fff) << 3); - printf("len %d id %d ", ip->ip_len, ip->ip_id); - printf("ttl %d p %d src %s", ip->ip_ttl, ip->ip_p, - inet_ntoa(ip->ip_src)); - if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) - printf(",%d", t->th_sport); - printf(" dst %s", inet_ntoa(ip->ip_dst)); - if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) - printf(",%d", t->th_dport); - if (ip->ip_p == IPPROTO_TCP) { - printf(" seq %lu:%lu flags ", - (u_long)t->th_seq, (u_long)t->th_ack); - for (j = 0, i = 1; i < 256; i *= 2, j++) - if (t->th_flags & i) - printf("%c", "FSRPAU--"[j]); - } - putchar('\n'); -} - - -int ip_resend(dev, mtu, r, gwip, datain) -char *dev; -int mtu; -struct in_addr gwip; -struct ipread *r; -char *datain; -{ - ether_header_t *eh; - char dhost[6]; - ip_t *ip; - int fd, wfd = initdevice(dev, 0, 5), len, i; - - if (datain) - fd = (*r->r_open)(datain); - else - fd = (*r->r_open)("-"); - - if (fd < 0) - exit(-1); - - ip = (struct ip *)pbuf; - eh = (ether_header_t *)malloc(sizeof(*eh)); - - bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost)); - if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1)) - { - perror("arp"); - return -2; - } - - while ((i = (*r->r_readip)((char *)pbuf, sizeof(pbuf), NULL, NULL)) > 0) - { - if (!(opts & OPT_RAW)) { - len = ntohs(ip->ip_len); - eh = (ether_header_t *)realloc((char *)eh, sizeof(*eh) + len); - eh->ether_type = htons((u_short)ETHERTYPE_IP); - if (!gwip.s_addr) { - if (arp((char *)&gwip, - (char *)A_A eh->ether_dhost) == -1) { - perror("arp"); - continue; - } - } else - bcopy(dhost, (char *)A_A eh->ether_dhost, - sizeof(dhost)); - if (!ip->ip_sum) - ip->ip_sum = chksum((u_short *)ip, - ip->ip_hl << 2); - bcopy(ip, (char *)(eh + 1), len); - len += sizeof(*eh); - printpacket(ip); - } else { - eh = (ether_header_t *)pbuf; - len = i; - } - - if (sendip(wfd, (char *)eh, len) == -1) - { - perror("send_packet"); - break; - } - } - (*r->r_close)(); - return 0; -} |