svn commit: trunk/busybox/networking: libiproute

vda at busybox.net vda at busybox.net
Sat Nov 1 00:10:52 UTC 2008


Author: vda
Date: 2008-10-31 17:10:51 -0700 (Fri, 31 Oct 2008)
New Revision: 23888

Log:
iplink: accept shorthands for "address" keyword here:
 "ip link set address 00:11:22:33:44:55"
ifupdown: use "addr" instead of "address"



Modified:
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/networking/libiproute/iplink.c


Changeset:
Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2008-10-31 17:22:59 UTC (rev 23887)
+++ trunk/busybox/networking/ifupdown.c	2008-11-01 00:10:51 UTC (rev 23888)
@@ -349,7 +349,7 @@
 	int result;
 #if ENABLE_FEATURE_IFUPDOWN_IP
 	result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec);
-	result += execute("ip link set[[ mtu %mtu%]][[ address %hwaddress%]] %iface% up", ifd, exec);
+	result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec);
 	/* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */
 	result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec);
 #else
@@ -433,7 +433,7 @@
 #if ENABLE_FEATURE_IFUPDOWN_IP
 	result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] "
 			"dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec);
-	result += execute("ip link set[[ mtu %mtu%]][[ address %hwaddress%]] %iface% up", ifd, exec);
+	result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec);
 	result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec);
 	return ((result == 3) ? 3 : 0);
 #else
@@ -500,7 +500,7 @@
 	unsigned i;
 #if ENABLE_FEATURE_IFUPDOWN_IP
 	/* ip doesn't up iface when it configures it (unlike ifconfig) */
-	if (!execute("ip link set[[ address %hwaddress%]] %iface% up", ifd, exec))
+	if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec))
 		return 0;
 #else
 	/* needed if we have hwaddress on dhcp iface */
@@ -519,7 +519,7 @@
 {
 #if ENABLE_FEATURE_IFUPDOWN_IP
 	/* ip doesn't up iface when it configures it (unlike ifconfig) */
-	if (!execute("ip link set[[ address %hwaddress%]] %iface% up", ifd, exec))
+	if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec))
 		return 0;
 #else
 	/* needed if we have hwaddress on dhcp iface */

Modified: trunk/busybox/networking/libiproute/iplink.c
===================================================================
--- trunk/busybox/networking/libiproute/iplink.c	2008-10-31 17:22:59 UTC (rev 23887)
+++ trunk/busybox/networking/libiproute/iplink.c	2008-11-01 00:10:51 UTC (rev 23888)
@@ -174,15 +174,18 @@
 	char *newname = NULL;
 	int htype, halen;
 	static const char keywords[] ALIGN1 =
-		"up\0""down\0""name\0""mtu\0""multicast\0""arp\0""address\0""dev\0";
-	enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_multicast, ARG_arp,
-		ARG_addr, ARG_dev };
+		"up\0""down\0""name\0""mtu\0""multicast\0"
+		"arp\0""address\0""dev\0";
+	enum { ARG_up = 0, ARG_down, ARG_name, ARG_mtu, ARG_multicast,
+		ARG_arp, ARG_addr, ARG_dev };
 	static const char str_on_off[] ALIGN1 = "on\0""off\0";
 	enum { PARM_on = 0, PARM_off };
 	smalluint key;
 
 	while (*argv) {
-		key = index_in_strings(keywords, *argv);
+		/* substring search ensures that e.g. "addr" and "address"
+		 * are both accepted */
+		key = index_in_substrings(keywords, *argv);
 		if (key == ARG_up) {
 			mask |= IFF_UP;
 			flags |= IFF_UP;



More information about the busybox-cvs mailing list