[BusyBox-cvs] busybox/networking Config.in,1.7,1.8 ifupdown.c,1.15,1.16
Glenn McGrath
bug1 at busybox.net
Mon Jan 13 21:40:41 UTC 2003
Update of /var/cvs/busybox/networking
In directory winder:/tmp/cvs-serv4799/networking
Modified Files:
Config.in ifupdown.c
Log Message:
Option to allow ifupdown use ip commands instead of ifconfig, add flush
command to ipaddr, patch by Bastian Blank
Index: Config.in
===================================================================
RCS file: /var/cvs/busybox/networking/Config.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Config.in 9 Jan 2003 10:06:01 -0000 1.7
+++ Config.in 13 Jan 2003 21:40:37 -0000 1.8
@@ -96,6 +96,13 @@
help
Please submit a patch to add help text for this item.
+config CONFIG_FEATURE_IFUPDOWN_IP
+ bool " Use ip applet"
+ default n
+ depends on CONFIG_IFUPDOWN && CONFIG_IP && CONFIG_FEATURE_IP_ADDRESS && CONFIG_FEATURE_IP_LINK && CONFIG_FEATURE_IP_ROUTE
+ help
+ Please submit a patch to add help text for this item.
+
config CONFIG_FEATURE_IFUPDOWN_IPV4
bool " Enable support for IPv4"
default y
@@ -104,14 +111,14 @@
Please submit a patch to add help text for this item.
config CONFIG_FEATURE_IFUPDOWN_IPV6
- bool " Enable support for IPv6 (requires ip command)"
+ bool " Enable support for IPv6"
default n
depends on CONFIG_IFUPDOWN
help
Please submit a patch to add help text for this item.
config CONFIG_FEATURE_IFUPDOWN_IPX
- bool " Enable support for IPX (requires ipx_interface command)"
+ bool " Enable support for IPX"
default n
depends on CONFIG_IFUPDOWN
help
Index: ifupdown.c
===================================================================
RCS file: /var/cvs/busybox/networking/ifupdown.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ifupdown.c 8 Dec 2002 01:23:39 -0000 1.15
+++ ifupdown.c 13 Jan 2003 21:40:37 -0000 1.16
@@ -307,22 +307,40 @@
#ifdef CONFIG_FEATURE_IFUPDOWN_IPV6
static int loopback_up6(interface_defn_t *ifd, execfn *exec)
{
- if (!execute("ifconfig %iface% add ::1", ifd, exec)) {
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% up", ifd, exec))
return(0);
- }
+ if (!execute("ip addr add ::1 dev %iface%", ifd, exec))
+ return(0);
+#else
+ if (!execute("ifconfig %iface% add ::1", ifd, exec))
+ return(0);
+#endif
return(1);
}
static int loopback_down6(interface_defn_t *ifd, execfn *exec)
{
- if (!execute("ifconfig %iface% del ::1", ifd, exec)) {
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% down", ifd, exec))
return(0);
- }
+#else
+ if (!execute("ifconfig %iface% del ::1", ifd, exec))
+ return(0);
+#endif
return(1);
}
static int static_up6(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% up", ifd, exec))
+ return(0);
+ if (!execute("ip addr add %address%/%netmask% dev %iface%", ifd, exec))
+ return(0);
+ if (!execute("[[ ip route add ::/0 via %gateway% ]]", ifd, exec))
+ return(0);
+#else
if (!execute("ifconfig %iface% [[media %media%]] [[hw %hwaddress%]] [[mtu %mtu%]] up", ifd, exec)) {
return(0);
}
@@ -332,17 +350,24 @@
if (!execute("[[ route -A inet6 add ::/0 gw %gateway% ]]", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
static int static_down6(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% down", ifd, exec))
+ return(0);
+#else
if (!execute("ifconfig %iface% down", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
static int v4tunnel_up(interface_defn_t *ifd, execfn *exec)
{
if (!execute("ip tunnel add %iface% mode sit remote %endpoint% [[local %local%]] [[ttl %ttl%]]", ifd, exec)) {
@@ -367,9 +392,12 @@
}
return(1);
}
+#endif
static method_t methods6[] = {
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
{ "v4tunnel", v4tunnel_up, v4tunnel_down, },
+#endif
{ "static", static_up6, static_down6, },
{ "loopback", loopback_up6, loopback_down6, },
};
@@ -384,22 +412,44 @@
#ifdef CONFIG_FEATURE_IFUPDOWN_IPV4
static int loopback_up(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% up", ifd, exec))
+ return(0);
+ if (!execute("ip addr add 127.0.0.1 dev %iface%", ifd, exec))
+ return(0);
+#else
if (!execute("ifconfig %iface% 127.0.0.1 up", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
static int loopback_down(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip -f inet addr flush dev %iface%", ifd, exec))
+ return(0);
+ if (!execute("ip link set %iface% down", ifd, exec))
+ return(0);
+#else
if (!execute("ifconfig %iface% 127.0.0.1 down", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
static int static_up(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("ip link set %iface% up", ifd, exec))
+ return(0);
+ if (!execute("ip addr add %address%/%netmask% dev %iface%", ifd, exec))
+ return(0);
+ if (!execute("[[ ip route add default via %gateway% dev %iface% ]]", ifd, exec))
+ return(0);
+#else
if (!execute("ifconfig %iface% %address% netmask %netmask% [[broadcast %broadcast%]] [[pointopoint %pointopoint%]] [[media %media%]] [[mtu %mtu%]] [[hw %hwaddress%]] up",
ifd, exec)) {
return(0);
@@ -407,17 +457,27 @@
if (!execute("[[ route add default gw %gateway% %iface% ]]", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
static int static_down(interface_defn_t *ifd, execfn *exec)
{
+#ifdef CONFIG_FEATURE_IFUPDOWN_IP
+ if (!execute("[[ ip route del default via %gateway% dev %iface% ]]", ifd, exec))
+ return(0);
+ if (!execute("ip -f inet addr flush dev %iface%", ifd, exec))
+ return(0);
+ if (!execute("ip link set %iface% down", ifd, exec))
+ return(0);
+#else
if (!execute("[[ route del default gw %gateway% %iface% ]]", ifd, exec)) {
return(0);
}
if (!execute("ifconfig %iface% down", ifd, exec)) {
return(0);
}
+#endif
return(1);
}
@@ -936,7 +996,6 @@
case 0: /* child */
execle("/bin/sh", "/bin/sh", "-c", str, NULL, environ);
exit(127);
- default: /* parent */
}
waitpid(child, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
More information about the busybox-cvs
mailing list