aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciek Borzecki <maciek.borzecki@gmail.com>2010-03-23 05:18:38 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-23 05:18:38 +0100
commit30ebd7bd7838787bdb7de0b484e37e442ab16ac5 (patch)
treeb8037f43f6283c8585bcded6fb5124944a3374aa
parent1c3f117ca4d1363177ed7c55c443ddaca9ddc668 (diff)
downloadbusybox-w32-30ebd7bd7838787bdb7de0b484e37e442ab16ac5.tar.gz
busybox-w32-30ebd7bd7838787bdb7de0b484e37e442ab16ac5.tar.bz2
busybox-w32-30ebd7bd7838787bdb7de0b484e37e442ab16ac5.zip
brctl: fixing stp parameters incompatibility
function old new delta static.stp_opts - 23 +23 brctl_main 1148 1169 +21 packed_usage 26786 26794 +8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/usage.h2
-rw-r--r--networking/brctl.c29
2 files changed, 18 insertions, 13 deletions
diff --git a/include/usage.h b/include/usage.h
index a7855cdf4..40cb6b2bb 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -187,7 +187,7 @@
187 "\n setpathcost BRIDGE COST Set path cost" \ 187 "\n setpathcost BRIDGE COST Set path cost" \
188 "\n setportprio BRIDGE PRIO Set port priority" \ 188 "\n setportprio BRIDGE PRIO Set port priority" \
189 "\n setbridgeprio BRIDGE PRIO Set bridge priority" \ 189 "\n setbridgeprio BRIDGE PRIO Set bridge priority" \
190 "\n stp BRIDGE [1|0] STP on/off" \ 190 "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off" \
191 ) \ 191 ) \
192 192
193#define bunzip2_trivial_usage \ 193#define bunzip2_trivial_usage \
diff --git a/networking/brctl.c b/networking/brctl.c
index e062dabb8..023518a26 100644
--- a/networking/brctl.c
+++ b/networking/brctl.c
@@ -32,7 +32,7 @@
32 32
33/* Maximum number of ports supported per bridge interface. */ 33/* Maximum number of ports supported per bridge interface. */
34#ifndef MAX_PORTS 34#ifndef MAX_PORTS
35#define MAX_PORTS 32 35# define MAX_PORTS 32
36#endif 36#endif
37 37
38/* Use internal number parsing and not the "exact" conversion. */ 38/* Use internal number parsing and not the "exact" conversion. */
@@ -40,26 +40,26 @@
40#define BRCTL_USE_INTERNAL 1 40#define BRCTL_USE_INTERNAL 1
41 41
42#if ENABLE_FEATURE_BRCTL_FANCY 42#if ENABLE_FEATURE_BRCTL_FANCY
43#include <linux/if_bridge.h> 43# include <linux/if_bridge.h>
44 44
45/* FIXME: These 4 funcs are not really clean and could be improved */ 45/* FIXME: These 4 funcs are not really clean and could be improved */
46static ALWAYS_INLINE void strtotimeval(struct timeval *tv, 46static ALWAYS_INLINE void strtotimeval(struct timeval *tv,
47 const char *time_str) 47 const char *time_str)
48{ 48{
49 double secs; 49 double secs;
50#if BRCTL_USE_INTERNAL 50# if BRCTL_USE_INTERNAL
51 char *endptr; 51 char *endptr;
52 secs = /*bb_*/strtod(time_str, &endptr); 52 secs = /*bb_*/strtod(time_str, &endptr);
53 if (endptr == time_str) 53 if (endptr == time_str)
54#else 54# else
55 if (sscanf(time_str, "%lf", &secs) != 1) 55 if (sscanf(time_str, "%lf", &secs) != 1)
56#endif 56# endif
57 bb_error_msg_and_die (bb_msg_invalid_arg, time_str, "timespec"); 57 bb_error_msg_and_die(bb_msg_invalid_arg, time_str, "timespec");
58 tv->tv_sec = secs; 58 tv->tv_sec = secs;
59 tv->tv_usec = 1000000 * (secs - tv->tv_sec); 59 tv->tv_usec = 1000000 * (secs - tv->tv_sec);
60} 60}
61 61
62static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv) 62static ALWAYS_INLINE unsigned long tv_to_jiffies(const struct timeval *tv)
63{ 63{
64 unsigned long long jif; 64 unsigned long long jif;
65 65
@@ -68,7 +68,7 @@ static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv)
68 return jif/10000; 68 return jif/10000;
69} 69}
70# if 0 70# if 0
71static void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies) 71static void jiffies_to_tv(struct timeval *tv, unsigned long jiffies)
72{ 72{
73 unsigned long long tvusec; 73 unsigned long long tvusec;
74 74
@@ -81,7 +81,7 @@ static unsigned long str_to_jiffies(const char *time_str)
81{ 81{
82 struct timeval tv; 82 struct timeval tv;
83 strtotimeval(&tv, time_str); 83 strtotimeval(&tv, time_str);
84 return __tv_to_jiffies(&tv); 84 return tv_to_jiffies(&tv);
85} 85}
86 86
87static void arm_ioctl(unsigned long *args, 87static void arm_ioctl(unsigned long *args,
@@ -220,9 +220,14 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
220 } 220 }
221#if ENABLE_FEATURE_BRCTL_FANCY 221#if ENABLE_FEATURE_BRCTL_FANCY
222 if (key == ARG_stp) { /* stp */ 222 if (key == ARG_stp) { /* stp */
223 /* FIXME: parsing yes/y/on/1 versus no/n/off/0 is too involved */ 223 static const char stp_opts[] ALIGN1 =
224 arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, 224 "0\0" "off\0" "n\0" "no\0" /* 0 .. 3 */
225 (unsigned)(**argv - '0'), 0); 225 "1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
226 int onoff = index_in_strings(stp_opts, *argv);
227 if (onoff < 0)
228 bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
229 onoff = (unsigned)onoff / 4;
230 arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0);
226 goto fire; 231 goto fire;
227 } 232 }
228 if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */ 233 if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */