svn commit: trunk/busybox/networking
vda at busybox.net
vda at busybox.net
Sat Sep 2 09:16:23 PDT 2006
Author: vda
Date: 2006-09-02 09:16:23 -0700 (Sat, 02 Sep 2006)
New Revision: 16028
Log:
ping6: resolve interface name to number early.
gcc is more efficient at truncating int to int16
via cast, use that instead of &.
Modified:
trunk/busybox/networking/ping.c
trunk/busybox/networking/ping6.c
Changeset:
Modified: trunk/busybox/networking/ping.c
===================================================================
--- trunk/busybox/networking/ping.c 2006-09-02 16:13:36 UTC (rev 16027)
+++ trunk/busybox/networking/ping.c 2006-09-02 16:16:23 UTC (rev 16028)
@@ -416,7 +416,7 @@
if (argc < 1)
bb_show_usage();
- myid = getpid() & 0xFFFF;
+ myid = (int16_t) getpid();
ping(*argv);
return EXIT_SUCCESS;
}
Modified: trunk/busybox/networking/ping6.c
===================================================================
--- trunk/busybox/networking/ping6.c 2006-09-02 16:13:36 UTC (rev 16027)
+++ trunk/busybox/networking/ping6.c 2006-09-02 16:16:23 UTC (rev 16028)
@@ -146,7 +146,7 @@
static struct sockaddr_in6 pingaddr;
static int pingsock = -1;
static int datalen; /* intentionally uninitialized to work around gcc bug */
-static char* ifname;
+static int if_index;
static long ntransmitted, nreceived, nrepeats, pingcount;
static int myid, options;
@@ -367,10 +367,8 @@
setsockopt(pingsock, SOL_IPV6, IPV6_HOPLIMIT, (char *) &sockopt,
sizeof(sockopt));
- if (ifname) {
- if ((pingaddr.sin6_scope_id = if_nametoindex(ifname)) == 0)
- bb_error_msg_and_die("%s: invalid interface name", ifname);
- }
+ if (if_index)
+ pingaddr.sin6_scope_id = if_index;
printf("PING %s (%s): %d data bytes\n",
hostent->h_name,
@@ -455,7 +453,10 @@
if (--argc <= 0)
bb_show_usage();
argv++;
- ifname = *argv;
+ if_index = if_nametoindex(*argv);
+ if (!if_index)
+ bb_error_msg_and_die(
+ "%s: invalid interface name", *argv);
break;
default:
bb_show_usage();
@@ -466,7 +467,7 @@
if (argc < 1)
bb_show_usage();
- myid = getpid() & 0xFFFF;
+ myid = (int16_t) getpid();
ping(*argv);
return EXIT_SUCCESS;
}
More information about the busybox-cvs
mailing list