* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
+ * ''This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * THIS SOFTWARE IS PROVIDED ''AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
* -- Van Jacobson (van@ee.lbl.gov)
* Tue Dec 20 03:50:13 PST 1988
*/
+//config:config TRACEROUTE
+//config: bool "traceroute (11 kb)"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Utility to trace the route of IP packets.
+//config:
+//config:config TRACEROUTE6
+//config: bool "traceroute6 (12 kb)"
+//config: default y
+//config: depends on FEATURE_IPV6
+//config: help
+//config: Utility to trace the route of IPv6 packets.
+//config:
+//config:config FEATURE_TRACEROUTE_VERBOSE
+//config: bool "Enable verbose output"
+//config: default y
+//config: depends on TRACEROUTE || TRACEROUTE6
+//config: help
+//config: Add some verbosity to traceroute. This includes among other things
+//config: hostnames and ICMP response types.
+//config:
+//config:config FEATURE_TRACEROUTE_USE_ICMP
+//config: bool "Enable -I option (use ICMP instead of UDP)"
+//config: default y
+//config: depends on TRACEROUTE || TRACEROUTE6
+
+/* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */
+//applet:IF_TRACEROUTE(APPLET(traceroute, BB_DIR_USR_BIN, BB_SUID_MAYBE))
+//applet:IF_TRACEROUTE6(APPLET(traceroute6, BB_DIR_USR_BIN, BB_SUID_MAYBE))
+
+//kbuild:lib-$(CONFIG_TRACEROUTE) += traceroute.o
+//kbuild:lib-$(CONFIG_TRACEROUTE6) += traceroute.o
//usage:#define traceroute_trivial_usage
//usage: "[-"IF_TRACEROUTE6("46")"FIlnrv] [-f 1ST_TTL] [-m MAXTTL] [-q PROBES] [-p PORT]\n"
# ifndef SOL_IPV6
# define SOL_IPV6 IPPROTO_IPV6
# endif
+# if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO)
+# define IPV6_RECVPKTINFO IPV6_PKTINFO
+# endif
#endif
#include "libbb.h"
# define IPPROTO_IP 0
#endif
+/* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have
+ * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for
+ * setsockopt (and take the same value as their corresponding SOL definitions,
+ * if they exist), we can just fall back on IPPROTO_RAW. */
+#ifndef SOL_RAW
+# define SOL_RAW IPPROTO_RAW
+#endif
+
#define OPT_STRING \
"FIlnrdvxt:i:m:p:q:s:w:z:f:" \
# if ENABLE_FEATURE_TRACEROUTE_VERBOSE
if (verbose) {
+# ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 80
+# endif
unsigned char *p;
char pa1[MAXHOSTNAMELEN];
char pa2[MAXHOSTNAMELEN];
INIT_G();
- /* minimum 1 arg */
- opt_complementary = "-1:x-x";
- op |= getopt32(argv, OPT_STRING
+ op |= getopt32(argv, "^"
+ OPT_STRING
+ "\0" "-1:x-x" /* minimum 1 arg */
, &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str
, &source, &waittime_str, &pausemsecs_str, &first_ttl_str
);
#if ENABLE_TRACEROUTE6
if (af == AF_INET6) {
xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock);
-# ifdef IPV6_RECVPKTINFO
setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO);
- setsockopt_1(rcvsock, SOL_IPV6, IPV6_2292PKTINFO);
-# else
- setsockopt_1(rcvsock, SOL_IPV6, IPV6_PKTINFO);
-# endif
} else
#endif
{
return 0;
}
+#if ENABLE_TRACEROUTE
int traceroute_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int traceroute_main(int argc UNUSED_PARAM, char **argv)
{
return common_traceroute_main(0, argv);
}
+#endif
#if ENABLE_TRACEROUTE6
int traceroute6_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;