summaryrefslogtreecommitdiff
path: root/networking/ping.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-11-20 18:12:12 +0100
committerDenys Vlasenko2009-11-20 18:12:12 +0100
commitad7d94bdc7d6a8ffe798a54f09e1e51dd949c9b7 (patch)
tree18eea693059760e3febdb2012ad2aee55a013279 /networking/ping.c
parent8684cbb5cc2c461e3795fba19ad7386db37cf499 (diff)
downloadbusybox-ad7d94bdc7d6a8ffe798a54f09e1e51dd949c9b7.zip
busybox-ad7d94bdc7d6a8ffe798a54f09e1e51dd949c9b7.tar.gz
ping6: do not play dirty tricks with argv
function old new delta common_ping_main - 368 +368 ping6_main 30 14 -16 ping_main 370 11 -359 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/2 up/down: 368/-375) Total: -7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ping.c')
-rw-r--r--networking/ping.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/networking/ping.c b/networking/ping.c
index d30eb5c..0ca41b9 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -30,13 +30,13 @@
#include "libbb.h"
#if ENABLE_PING6
-#include <netinet/icmp6.h>
+# include <netinet/icmp6.h>
/* I see RENUMBERED constants in bits/in.h - !!?
* What a fuck is going on with libc? Is it a glibc joke? */
-#ifdef IPV6_2292HOPLIMIT
-#undef IPV6_HOPLIMIT
-#define IPV6_HOPLIMIT IPV6_2292HOPLIMIT
-#endif
+# ifdef IPV6_2292HOPLIMIT
+# undef IPV6_HOPLIMIT
+# define IPV6_HOPLIMIT IPV6_2292HOPLIMIT
+# endif
#endif
enum {
@@ -173,13 +173,14 @@ static void ping6(len_and_sockaddr *lsa)
}
#endif
-int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ping_main(int argc UNUSED_PARAM, char **argv)
+#if !ENABLE_PING6
+# define common_ping_main(af, argv) common_ping_main(argv)
+#endif
+static int common_ping_main(sa_family_t af, char **argv)
{
len_and_sockaddr *lsa;
-#if ENABLE_PING6
- sa_family_t af = AF_UNSPEC;
+#if ENABLE_PING6
while ((++argv)[0] && argv[0][0] == '-') {
if (argv[0][1] == '4') {
af = AF_INET;
@@ -716,12 +717,10 @@ static void ping(len_and_sockaddr *lsa)
ping4(lsa);
}
-int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int ping_main(int argc UNUSED_PARAM, char **argv)
+static int common_ping_main(int opt, char **argv)
{
len_and_sockaddr *lsa;
char *str_s;
- int opt;
INIT_G();
@@ -765,13 +764,25 @@ int ping_main(int argc UNUSED_PARAM, char **argv)
#endif /* FEATURE_FANCY_PING */
+int ping_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int ping_main(int argc UNUSED_PARAM, char **argv)
+{
+#if !ENABLE_FEATURE_FANCY_PING
+ return common_ping_main(AF_UNSPEC, argv);
+#else
+ return common_ping_main(0, argv);
+#endif
+}
+
#if ENABLE_PING6
int ping6_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ping6_main(int argc UNUSED_PARAM, char **argv)
{
- argv[0] = (char*)"-6";
- return ping_main(0 /* argc+1 - but it's unused anyway */,
- argv - 1);
+# if !ENABLE_FEATURE_FANCY_PING
+ return common_ping_main(AF_INET6, argv);
+# else
+ return common_ping_main(OPT_IPV6, argv);
+# endif
}
#endif