aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-03 18:19:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-03 18:19:02 +0000
commit6edaddec0238c6b7558c47fe24e33fae703385b5 (patch)
tree1f7fbb690559396580c46dcb10ebf764b4d12aff
parentf0a97fb43ab1ccab1904e7bc947a97c6e795900e (diff)
downloadbusybox-w32-6edaddec0238c6b7558c47fe24e33fae703385b5.tar.gz
busybox-w32-6edaddec0238c6b7558c47fe24e33fae703385b5.tar.bz2
busybox-w32-6edaddec0238c6b7558c47fe24e33fae703385b5.zip
traceroute: fix compilation if netinet/protocols.h is missing
-rw-r--r--networking/traceroute.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index ceec0bc9c..80ce5c3ee 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -204,27 +204,11 @@
204#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP 204#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
205//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP 205//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
206 206
207#include <errno.h>
208#include <stdio.h>
209#include <stdlib.h>
210#include <string.h>
211#include <unistd.h>
212#include <fcntl.h>
213#include <netdb.h>
214#include <endian.h>
215#include <getopt.h>
216
217#include <sys/param.h>
218#include <sys/file.h>
219#include <sys/ioctl.h>
220#include <sys/socket.h>
221#include <sys/select.h>
222#include "inet_common.h" 207#include "inet_common.h"
223 208
224#include <net/if.h> 209#include <net/if.h>
225#include <netinet/in.h>
226#include <arpa/inet.h> 210#include <arpa/inet.h>
227#include <netinet/protocols.h> 211#include <netinet/in.h>
228#include <netinet/udp.h> 212#include <netinet/udp.h>
229#include <netinet/ip.h> 213#include <netinet/ip.h>
230#include <netinet/ip_icmp.h> 214#include <netinet/ip_icmp.h>
@@ -236,7 +220,15 @@
236 * Definitions for internet protocol version 4. 220 * Definitions for internet protocol version 4.
237 * Per RFC 791, September 1981. 221 * Per RFC 791, September 1981.
238 */ 222 */
239#define IPVERSION 4 223#define IPVERSION 4
224
225#ifndef IPPROTO_ICMP
226/* Grrrr.... */
227#define IPPROTO_ICMP 1
228#endif
229#ifndef IPPROTO_IP
230#define IPPROTO_IP 0
231#endif
240 232
241/* 233/*
242 * Overlay for ip header used by other protocols (tcp, udp). 234 * Overlay for ip header used by other protocols (tcp, udp).
@@ -1080,7 +1072,7 @@ traceroute_main(int argc, char *argv[])
1080 if (n > 2) 1072 if (n > 2)
1081 close(n); 1073 close(n);
1082 1074
1083 s = xsocket(AF_INET, SOCK_RAW, IP_ICMP); 1075 s = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
1084 1076
1085#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG 1077#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
1086 if (op & USAGE_OP_DEBUG) 1078 if (op & USAGE_OP_DEBUG)
@@ -1098,10 +1090,6 @@ traceroute_main(int argc, char *argv[])
1098 if (lsrr > 0) { 1090 if (lsrr > 0) {
1099 unsigned char optlist[MAX_IPOPTLEN]; 1091 unsigned char optlist[MAX_IPOPTLEN];
1100 1092
1101 cp = "ip";
1102 if ((pe = getprotobyname(cp)) == NULL)
1103 bb_perror_msg_and_die("unknown protocol");
1104
1105 /* final hop */ 1093 /* final hop */
1106 gwlist[lsrr] = to->sin_addr.s_addr; 1094 gwlist[lsrr] = to->sin_addr.s_addr;
1107 ++lsrr; 1095 ++lsrr;
@@ -1116,10 +1104,10 @@ traceroute_main(int argc, char *argv[])
1116 optlist[3] = IPOPT_MINOFF; 1104 optlist[3] = IPOPT_MINOFF;
1117 memcpy(optlist + 4, gwlist, i); 1105 memcpy(optlist + 4, gwlist, i);
1118 1106
1119 if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS, 1107 if ((setsockopt(sndsock, IPPROTO_IP, IP_OPTIONS,
1120 (char *)optlist, i + sizeof(gwlist[0]))) < 0) { 1108 (char *)optlist, i + sizeof(gwlist[0]))) < 0) {
1121 bb_perror_msg_and_die("IP_OPTIONS"); 1109 bb_perror_msg_and_die("IP_OPTIONS");
1122 } 1110 }
1123 } 1111 }
1124#endif /* IP_OPTIONS */ 1112#endif /* IP_OPTIONS */
1125#endif /* CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE */ 1113#endif /* CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE */