#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <endian.h>
-#include <getopt.h>
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/select.h>
#include "inet_common.h"
#include <net/if.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
-#include <netinet/protocols.h>
+#include <netinet/in.h>
#include <netinet/udp.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
*/
-#define IPVERSION 4
+#define IPVERSION 4
+
+#ifndef IPPROTO_ICMP
+/* Grrrr.... */
+#define IPPROTO_ICMP 1
+#endif
+#ifndef IPPROTO_IP
+#define IPPROTO_IP 0
+#endif
/*
* Overlay for ip header used by other protocols (tcp, udp).
outicmp->icmp_cksum = 0xffff;
} else
#endif
- if (doipcksum) {
+ if (doipcksum) {
/* Checksum (we must save and restore ip header) */
tip = *outip;
ui = (struct udpiphdr *)outip;
if (cc < 0)
bb_perror_msg_and_die("sendto");
printf("%s: wrote %s %d chars, ret=%d\n",
- bb_applet_name, hostname, packlen, cc);
+ applet_name, hostname, packlen, cc);
(void)fflush(stdout);
}
}
return (type == ICMP_TIMXCEED ? -1 : code + 1);
} else
#endif
- {
+ {
up = (struct udphdr *)((unsigned char *)hip + hlen);
/* XXX 8 is a magic number */
if (hlen + 12 <= cc &&
opterr = 0;
#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
- bb_opt_complementally = "x-x:g::";
+ opt_complementary = "x-x:g::";
#else
- bb_opt_complementally = "x-x";
+ opt_complementary = "x-x";
#endif
- op = bb_getopt_ulflags(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
+ op = getopt32(argc, argv, "FIlnrdvxt:i:m:p:q:s:w:z:f:"
#define USAGE_OP_DONT_FRAGMNT (1<<0) /* F */
#define USAGE_OP_USE_ICMP (1<<1) /* I */
#define USAGE_OP_TTL_FLAG (1<<2) /* l */
if(nprobes_str)
nprobes = str2val(nprobes_str, "nprobes", 1, -1);
if(source) {
- /*
- * set the ip source address of the outbound
- * probe (e.g., on a multi-homed host).
- */
- if (getuid()) bb_error_msg_and_die("-s %s: Permission denied", source);
+ /*
+ * set the ip source address of the outbound
+ * probe (e.g., on a multi-homed host).
+ */
+ if (getuid()) bb_error_msg_and_die("-s %s: permission denied", source);
}
if(waittime_str)
waittime = str2val(waittime_str, "wait time", 2, 24 * 60 * 60);
for(l_sr = sourse_route_list; l_sr; ) {
if (lsrr >= NGATEWAYS)
- bb_error_msg_and_die("No more than %d gateways", NGATEWAYS);
+ bb_error_msg_and_die("no more than %d gateways", NGATEWAYS);
getaddr(gwlist + lsrr, l_sr->data);
++lsrr;
l_sr = l_sr->link;
if (n > 2)
close(n);
- s = xsocket(AF_INET, SOCK_RAW, IP_ICMP);
+ s = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
if (op & USAGE_OP_DEBUG)
if (lsrr > 0) {
unsigned char optlist[MAX_IPOPTLEN];
- cp = "ip";
- if ((pe = getprotobyname(cp)) == NULL)
- bb_perror_msg_and_die("unknown protocol");
-
/* final hop */
gwlist[lsrr] = to->sin_addr.s_addr;
++lsrr;
optlist[3] = IPOPT_MINOFF;
memcpy(optlist + 4, gwlist, i);
- if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS,
+ if ((setsockopt(sndsock, IPPROTO_IP, IP_OPTIONS,
(char *)optlist, i + sizeof(gwlist[0]))) < 0) {
bb_perror_msg_and_die("IP_OPTIONS");
- }
+ }
}
#endif /* IP_OPTIONS */
#endif /* CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE */