Ignore machine-check MSRs
[freebsd-src/fkvm-freebsd.git] / contrib / ipfilter / ipsend / ipresend.c
blob050aecf2093c5692a36297bb204265f77cc2b632
1 /* $FreeBSD$ */
3 /*
4 * ipresend.c (C) 1995-1998 Darren Reed
6 * See the IPFILTER.LICENCE file for details on licencing.
8 */
9 #if !defined(lint)
10 static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
11 static const char rcsid[] = "@(#)$Id: ipresend.c,v 2.4 2004/01/08 13:34:31 darrenr Exp $";
12 #endif
13 #include <sys/param.h>
14 #include <sys/types.h>
15 #include <sys/time.h>
16 #include <sys/socket.h>
17 #include <netinet/in.h>
18 #include <arpa/inet.h>
19 #include <netinet/in_systm.h>
20 #include <netinet/ip.h>
21 #ifndef linux
22 #include <netinet/ip_var.h>
23 #endif
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <netdb.h>
28 #include <string.h>
29 #include "ipsend.h"
32 extern char *optarg;
33 extern int optind;
34 #ifndef NO_IPF
35 extern struct ipread snoop, pcap, etherf, iphex, tcpd, iptext;
36 #endif
38 int opts = 0;
39 #ifndef DEFAULT_DEVICE
40 # ifdef linux
41 char default_device[] = "eth0";
42 # else
43 # ifdef sun
44 char default_device[] = "le0";
45 # else
46 # ifdef ultrix
47 char default_device[] = "ln0";
48 # else
49 # ifdef __bsdi__
50 char default_device[] = "ef0";
51 # else
52 # ifdef __sgi
53 char default_device[] = "ec0";
54 # else
55 char default_device[] = "lan0";
56 # endif
57 # endif
58 # endif
59 # endif
60 # endif
61 #else
62 char default_device[] = DEFAULT_DEVICE;
63 #endif
66 static void usage __P((char *));
67 int main __P((int, char **));
70 static void usage(prog)
71 char *prog;
73 fprintf(stderr, "Usage: %s [options] <-r filename|-R filename>\n\
74 \t\t-r filename\tsnoop data file to resend\n\
75 \t\t-R filename\tlibpcap data file to resend\n\
76 \toptions:\n\
77 \t\t-d device\tSend out on this device\n\
78 \t\t-g gateway\tIP gateway to use if non-local dest.\n\
79 \t\t-m mtu\t\tfake MTU to use when sending out\n\
80 ", prog);
81 exit(1);
85 int main(argc, argv)
86 int argc;
87 char **argv;
89 struct in_addr gwip;
90 struct ipread *ipr = NULL;
91 char *name = argv[0], *gateway = NULL, *dev = NULL;
92 char *resend = NULL;
93 int mtu = 1500, c;
95 while ((c = getopt(argc, argv, "EHPRSTXd:g:m:r:")) != -1)
96 switch (c)
98 case 'd' :
99 dev = optarg;
100 break;
101 case 'g' :
102 gateway = optarg;
103 break;
104 case 'm' :
105 mtu = atoi(optarg);
106 if (mtu < 28)
108 fprintf(stderr, "mtu must be > 28\n");
109 exit(1);
111 case 'r' :
112 resend = optarg;
113 break;
114 case 'R' :
115 opts |= OPT_RAW;
116 break;
117 #ifndef NO_IPF
118 case 'E' :
119 ipr = &etherf;
120 break;
121 case 'H' :
122 ipr = &iphex;
123 break;
124 case 'P' :
125 ipr = &pcap;
126 break;
127 case 'S' :
128 ipr = &snoop;
129 break;
130 case 'T' :
131 ipr = &tcpd;
132 break;
133 case 'X' :
134 ipr = &iptext;
135 break;
136 #endif
137 default :
138 fprintf(stderr, "Unknown option \"%c\"\n", c);
139 usage(name);
142 if (!ipr || !resend)
143 usage(name);
145 gwip.s_addr = 0;
146 if (gateway && resolve(gateway, (char *)&gwip) == -1)
148 fprintf(stderr,"Cant resolve %s\n", gateway);
149 exit(2);
152 if (!dev)
153 dev = default_device;
155 printf("Device: %s\n", dev);
156 printf("Gateway: %s\n", inet_ntoa(gwip));
157 printf("mtu: %d\n", mtu);
159 return ip_resend(dev, mtu, ipr, gwip, resend);