2 * ipresend.c (C) 1995-1998 Darren Reed
4 * This was written to test what size TCP fragments would get through
5 * various TCP/IP packet filters, as used in IP firewalls. In certain
6 * conditions, enough of the TCP header is missing for unpredictable
7 * results unless the filter is aware that this can happen.
9 * See the IPFILTER.LICENCE file for details on licencing.
11 #if defined(__sgi) && (IRIX > 602)
12 # include <sys/ptimers.h>
19 #include <sys/types.h>
20 #include <sys/param.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
25 #include <netinet/in_systm.h>
26 #include <netinet/ip.h>
27 #include <netinet/tcp.h>
28 #include <netinet/udp.h>
29 #include <netinet/ip_icmp.h>
31 #include <netinet/ip_var.h>
36 static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
37 static const char rcsid[] = "@(#)$Id: ipresend.c,v 2.1.4.4 2002/12/06 11:40:35 darrenr Exp $";
44 extern struct ipread snoop, pcap, etherf, iphex, tcpd, iptext;
48 #ifndef DEFAULT_DEVICE
50 char default_device[] = "eth0";
53 char default_device[] = "le0";
56 char default_device[] = "ln0";
59 char default_device[] = "ef0";
62 char default_device[] = "ec0";
64 char default_device[] = "lan0";
71 char default_device[] = DEFAULT_DEVICE;
75 static void usage __P((char *));
76 int main __P((int, char **));
79 static void usage(prog)
82 fprintf(stderr, "Usage: %s [options] <-r filename|-R filename>\n\
83 \t\t-r filename\tsnoop data file to resend\n\
84 \t\t-R filename\tlibpcap data file to resend\n\
86 \t\t-d device\tSend out on this device\n\
87 \t\t-g gateway\tIP gateway to use if non-local dest.\n\
88 \t\t-m mtu\t\tfake MTU to use when sending out\n\
99 struct ipread *ipr = NULL;
100 char *name = argv[0], *gateway = NULL, *dev = NULL;
104 while ((c = getopt(argc, argv, "EHPRSTXd:g:m:r:")) != -1)
117 fprintf(stderr, "mtu must be > 28\n");
147 fprintf(stderr, "Unknown option \"%c\"\n", c);
155 if (gateway && resolve(gateway, (char *)&gwip) == -1)
157 fprintf(stderr,"Cant resolve %s\n", gateway);
162 dev = default_device;
164 printf("Device: %s\n", dev);
165 printf("Gateway: %s\n", inet_ntoa(gwip));
166 printf("mtu: %d\n", mtu);
168 return ip_resend(dev, mtu, ipr, gwip, resend);