svn commit: trunk/busybox: include libbb networking

Bernhard Fischer rep.dot.nop at gmail.com
Fri Feb 9 11:14:07 PST 2007


On Fri, Feb 09, 2007 at 07:49:44PM +0100, Bernhard Fischer wrote:
>On Fri, Feb 09, 2007 at 09:32:17AM -0800, vda at busybox.net wrote:
>>Author: vda
>>Date: 2007-02-09 09:32:16 -0800 (Fri, 09 Feb 2007)
>>New Revision: 17842
>>
>>Log:
>>ping: support -I addr in family neutral manner; reuse a bit of common code
>
>>Modified: trunk/busybox/include/usage.h
>>===================================================================
>>--- trunk/busybox/include/usage.h	2007-02-09 17:30:14 UTC (rev 17841)
>>+++ trunk/busybox/include/usage.h	2007-02-09 17:32:16 UTC (rev 17842)
>>@@ -2428,20 +2428,22 @@
>> #define ping_full_usage \
>>        "Send ICMP ECHO_REQUEST packets to network hosts" \
>>        "\n\nOptions:\n" \
>>-       "	-c CNT	Send only CNT pings\n" \
>>-       "	-s SIZE	Send SIZE data bytes in packets (default=56)\n" \
>>-       "	-I IP	Use IP as source address\n" \
>>-       "	-q	Quiet mode, only displays output at start\n" \
>>-       "		and when finished"
>>+       "	-4, -6		Force IPv4 or IPv6 hostname resolution\n" \
>
>s/resolution/resolving/g
>
>btw (re: usage.h)
>let me suggest the attached stripping of redundant information in
>busybox_main.

And embarassingly enough i forgot to attach said hunks..
Attached now, sorry for the noise. <skip rest>

>Furthermore, That helptext should really be moved to usage.h to be able
>to compress it, just as a sidenote ;)
>
>
>>+       "	-c CNT		Send only CNT pings\n" \
>>+       "	-s SIZE		Send SIZE data bytes in packets (default=56)\n" \
>>+       "	-I iface/IP	Use interface or IP address as source\n" \
>>+       "	-q		Quiet mode, only displays output at start\n" \
>>+       "			and when finished"
>> #define ping6_trivial_usage \
>>        "[OPTION]... host"
>> #define ping6_full_usage \
>>        "Send ICMP ECHO_REQUEST packets to network hosts" \
>>        "\n\nOptions:\n" \
>>-       "	-c CNT	Send only CNT pings\n" \
>>-       "	-s SIZE	Send SIZE data bytes in packets (default=56)\n" \
>>-       "	-q	Quiet mode, only displays output at start\n" \
>>-       "		and when finished"
>
>"Be quiet."
>should suffice, really
>
>>+       "	-c CNT		Send only CNT pings\n" \
>>+       "	-s SIZE		Send SIZE data bytes in packets (default=56)\n" \
>>+       "	-I iface/IP	Use interface or IP address as source\n" \
>>+       "	-q		Quiet mode, only displays output at start\n" \
>>+       "			and when finished"
>
>ditto
>
>>Modified: trunk/busybox/networking/ping.c
>>===================================================================
>>--- trunk/busybox/networking/ping.c	2007-02-09 17:30:14 UTC (rev 17841)
>>+++ trunk/busybox/networking/ping.c	2007-02-09 17:32:16 UTC (rev 17842)
>>@@ -254,7 +254,7 @@
>> 	struct sockaddr_in6 sin6;
>> #endif
>> } pingaddr;
>>-static struct sockaddr_in sourceaddr;
>>+static len_and_sockaddr *source_lsa;
>> static int pingsock = -1;
>> static unsigned datalen; /* intentionally uninitialized to work around gcc bug */
>/* huh? what bug, exactly? */
> 
>>@@ -561,9 +561,8 @@
>> 
>> 	pingsock = create_icmp_socket();
>> 	pingaddr.sin = lsa->sin;
>>-	if (sourceaddr.sin_addr.s_addr) {
>>-		xbind(pingsock, (struct sockaddr*)&sourceaddr, sizeof(sourceaddr));
>>-	}
>>+	if (source_lsa)
>>+		xbind(pingsock, &lsa->sa, lsa->len);
>
>Didn't look, but are there any users that can't rely on xbind using
>#parm2->len so we could drop that explicit len parm?
> 
>> 	/* enable broadcast pings */
>> 	setsockopt_broadcast(pingsock);
>
>>@@ -695,25 +685,21 @@
>> }
>> #endif
>> 
>>-/* TODO: consolidate ether-wake.c, dnsd.c, ifupdown.c, nslookup.c
>>- * versions of below thing. BTW we have far too many "%u.%u.%u.%u" too...
>>-*/
>>-static int parse_nipquad(const char *str, struct sockaddr_in* addr)
>>+static void ping(len_and_sockaddr *lsa)
>
>const len_and_sockaddr * const lsa , perhaps?
>
>>@@ -732,9 +718,11 @@
>> 	if (option_mask32 & OPT_s) datalen = xatou16(opt_s); // -s
>> 	if (option_mask32 & OPT_I) { // -I
>> 		if_index = if_nametoindex(opt_I);
>>-		if (!if_index)
>>-			if (parse_nipquad(opt_I, &sourceaddr))
>>-				bb_show_usage();
>>+		if (!if_index) {
>>+			/* TODO: I'm not sure it takes IPv6 unless in [XX:XX..] format */
>
>I'm unsure whether the decision to require that [XX:XX..] format was a
>good idea since it sounds to be non-standard to me
>
>cheers,
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox.shring-bare-helptext.00.diff
Type: text/x-diff
Size: 1002 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070209/785b565f/attachment.bin 


More information about the busybox mailing list