aboutsummaryrefslogtreecommitdiff
path: root/networking/ifupdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/ifupdown.c')
-rw-r--r--networking/ifupdown.c135
1 files changed, 127 insertions, 8 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 1d0fc53cf..7ac517afd 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * ifupdown for busybox 3 * ifup/ifdown for busybox
4 * Copyright (c) 2002 Glenn McGrath 4 * Copyright (c) 2002 Glenn McGrath
5 * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> 5 * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org>
6 * 6 *
@@ -17,10 +17,127 @@
17 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 17 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
18 */ 18 */
19 19
20//config:config IFUP
21//config: bool "ifup"
22//config: default y
23//config: help
24//config: Activate the specified interfaces. This applet makes use
25//config: of either "ifconfig" and "route" or the "ip" command to actually
26//config: configure network interfaces. Therefore, you will probably also want
27//config: to enable either IFCONFIG and ROUTE, or enable
28//config: FEATURE_IFUPDOWN_IP and the various IP options. Of
29//config: course you could use non-busybox versions of these programs, so
30//config: against my better judgement (since this will surely result in plenty
31//config: of support questions on the mailing list), I do not force you to
32//config: enable these additional options. It is up to you to supply either
33//config: "ifconfig", "route" and "run-parts" or the "ip" command, either
34//config: via busybox or via standalone utilities.
35//config:
36//config:config IFDOWN
37//config: bool "ifdown"
38//config: default y
39//config: help
40//config: Deactivate the specified interfaces.
41//config:
42//config:config IFUPDOWN_IFSTATE_PATH
43//config: string "Absolute path to ifstate file"
44//config: default "/var/run/ifstate"
45//config: depends on IFUP || IFDOWN
46//config: help
47//config: ifupdown keeps state information in a file called ifstate.
48//config: Typically it is located in /var/run/ifstate, however
49//config: some distributions tend to put it in other places
50//config: (debian, for example, uses /etc/network/run/ifstate).
51//config: This config option defines location of ifstate.
52//config:
53//config:config FEATURE_IFUPDOWN_IP
54//config: bool "Use ip applet"
55//config: default y
56//config: depends on IFUP || IFDOWN
57//config: help
58//config: Use the iproute "ip" command to implement "ifup" and "ifdown", rather
59//config: than the default of using the older 'ifconfig' and 'route' utilities.
60//config:
61//config:config FEATURE_IFUPDOWN_IP_BUILTIN
62//config: bool "Use busybox ip applet"
63//config: default y
64//config: depends on FEATURE_IFUPDOWN_IP
65//config: select PLATFORM_LINUX
66//config: select IP
67//config: select FEATURE_IP_ADDRESS
68//config: select FEATURE_IP_LINK
69//config: select FEATURE_IP_ROUTE
70//config: help
71//config: Use the busybox iproute "ip" applet to implement "ifupdown".
72//config:
73//config: If left disabled, you must install the full-blown iproute2
74//config: utility or the "ifup" and "ifdown" applets will not work.
75//config:
76//config:config FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
77//config: bool "Use busybox ifconfig and route applets"
78//config: default n
79//config: depends on (IFUP || IFDOWN) && !FEATURE_IFUPDOWN_IP
80//config: select IFCONFIG
81//config: select ROUTE
82//config: help
83//config: Use the busybox iproute "ifconfig" and "route" applets to
84//config: implement the "ifup" and "ifdown" utilities.
85//config:
86//config: If left disabled, you must install the full-blown ifconfig
87//config: and route utilities, or the "ifup" and "ifdown" applets will not
88//config: work.
89//config:
90//config:config FEATURE_IFUPDOWN_IPV4
91//config: bool "Support for IPv4"
92//config: default y
93//config: depends on IFUP || IFDOWN
94//config: help
95//config: If you want ifup/ifdown to talk IPv4, leave this on.
96//config:
97//config:config FEATURE_IFUPDOWN_IPV6
98//config: bool "Support for IPv6"
99//config: default y
100//config: depends on (IFUP || IFDOWN) && FEATURE_IPV6
101//config: help
102//config: If you need support for IPv6, turn this option on.
103//config:
104//UNUSED:
105////////:config FEATURE_IFUPDOWN_IPX
106////////: bool "Support for IPX"
107////////: default y
108////////: depends on IFUP || IFDOWN
109////////: help
110////////: If this option is selected you can use busybox to work with IPX
111////////: networks.
112//config:
113//config:config FEATURE_IFUPDOWN_MAPPING
114//config: bool "Enable mapping support"
115//config: default y
116//config: depends on IFUP || IFDOWN
117//config: help
118//config: This enables support for the "mapping" stanza, unless you have
119//config: a weird network setup you don't need it.
120//config:
121//config:config FEATURE_IFUPDOWN_EXTERNAL_DHCP
122//config: bool "Support for external dhcp clients"
123//config: default n
124//config: depends on IFUP || IFDOWN
125//config: help
126//config: This enables support for the external dhcp clients. Clients are
127//config: tried in the following order: dhcpcd, dhclient, pump and udhcpc.
128//config: Otherwise, if udhcpc applet is enabled, it is used.
129//config: Otherwise, ifup/ifdown will have no support for DHCP.
130
131//applet:IF_IFUP(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup))
132//applet:IF_IFDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
133
134//kbuild:lib-$(CONFIG_IFUP) += ifupdown.o
135//kbuild:lib-$(CONFIG_IFDOWN) += ifupdown.o
136
20//usage:#define ifup_trivial_usage 137//usage:#define ifup_trivial_usage
21//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." 138//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
22//usage:#define ifup_full_usage "\n\n" 139//usage:#define ifup_full_usage "\n\n"
23//usage: " -a De/configure all interfaces automatically" 140//usage: " -a Configure all interfaces"
24//usage: "\n -i FILE Use FILE instead of /etc/network/interfaces" 141//usage: "\n -i FILE Use FILE instead of /etc/network/interfaces"
25//usage: "\n -n Print out what would happen, but don't do it" 142//usage: "\n -n Print out what would happen, but don't do it"
26//usage: IF_FEATURE_IFUPDOWN_MAPPING( 143//usage: IF_FEATURE_IFUPDOWN_MAPPING(
@@ -28,12 +145,12 @@
28//usage: "\n -m Don't run any mappings" 145//usage: "\n -m Don't run any mappings"
29//usage: ) 146//usage: )
30//usage: "\n -v Print out what would happen before doing it" 147//usage: "\n -v Print out what would happen before doing it"
31//usage: "\n -f Force de/configuration" 148//usage: "\n -f Force configuration"
32//usage: 149//usage:
33//usage:#define ifdown_trivial_usage 150//usage:#define ifdown_trivial_usage
34//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." 151//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
35//usage:#define ifdown_full_usage "\n\n" 152//usage:#define ifdown_full_usage "\n\n"
36//usage: " -a De/configure all interfaces automatically" 153//usage: " -a Deconfigure all interfaces"
37//usage: "\n -i FILE Use FILE for interface definitions" 154//usage: "\n -i FILE Use FILE for interface definitions"
38//usage: "\n -n Print out what would happen, but don't do it" 155//usage: "\n -n Print out what would happen, but don't do it"
39//usage: IF_FEATURE_IFUPDOWN_MAPPING( 156//usage: IF_FEATURE_IFUPDOWN_MAPPING(
@@ -41,7 +158,7 @@
41//usage: "\n -m Don't run any mappings" 158//usage: "\n -m Don't run any mappings"
42//usage: ) 159//usage: )
43//usage: "\n -v Print out what would happen before doing it" 160//usage: "\n -v Print out what would happen before doing it"
44//usage: "\n -f Force de/configuration" 161//usage: "\n -f Force deconfiguration"
45 162
46#include "libbb.h" 163#include "libbb.h"
47#include "common_bufsiz.h" 164#include "common_bufsiz.h"
@@ -1248,7 +1365,6 @@ static FILE *open_new_state_file(void)
1248 return xfdopen_for_write(fd); 1365 return xfdopen_for_write(fd);
1249} 1366}
1250 1367
1251
1252int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1368int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1253int ifupdown_main(int argc UNUSED_PARAM, char **argv) 1369int ifupdown_main(int argc UNUSED_PARAM, char **argv)
1254{ 1370{
@@ -1263,10 +1379,13 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv)
1263 G.startup_PATH = getenv("PATH"); 1379 G.startup_PATH = getenv("PATH");
1264 G.shell = xstrdup(get_shell_name()); 1380 G.shell = xstrdup(get_shell_name());
1265 1381
1266 cmds = iface_down; 1382 if (ENABLE_IFUP
1267 if (applet_name[2] == 'u') { 1383 && (!ENABLE_IFDOWN || applet_name[2] == 'u')
1384 ) {
1268 /* ifup command */ 1385 /* ifup command */
1269 cmds = iface_up; 1386 cmds = iface_up;
1387 } else {
1388 cmds = iface_down;
1270 } 1389 }
1271 1390
1272 getopt32(argv, OPTION_STR, &interfaces); 1391 getopt32(argv, OPTION_STR, &interfaces);