mirror of https://github.com/mirror/busybox.git
brctl: fold show_bridge_ports_ into its caller
function old new delta brctl_main 2235 2171 -64 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>1_32_stable
parent
3398753818
commit
b4fa16d5ed
|
@ -390,28 +390,6 @@ static void show_bridge_port(const char *name)
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_bridge_ports(const char *name)
|
|
||||||
{
|
|
||||||
DIR *ifaces;
|
|
||||||
struct dirent *ent;
|
|
||||||
char pathbuf[IFNAMSIZ + sizeof("/brif") + 8];
|
|
||||||
|
|
||||||
#if IFNAMSIZ == 16
|
|
||||||
sprintf(pathbuf, "%.16s/brif", name);
|
|
||||||
#else
|
|
||||||
sprintf(pathbuf, "%.*s/brif", (int)IFNAMSIZ, name);
|
|
||||||
#endif
|
|
||||||
ifaces = opendir(pathbuf);
|
|
||||||
if (ifaces) {
|
|
||||||
while ((ent = readdir(ifaces)) != NULL) {
|
|
||||||
if (DOT_OR_DOTDOT(ent->d_name))
|
|
||||||
continue; /* . or .. */
|
|
||||||
show_bridge_port(ent->d_name);
|
|
||||||
}
|
|
||||||
closedir(ifaces);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void show_bridge_stp(const char *name)
|
static void show_bridge_stp(const char *name)
|
||||||
{
|
{
|
||||||
char pathbuf[IFNAMSIZ + sizeof("/bridge/topology_change_timer") + 8];
|
char pathbuf[IFNAMSIZ + sizeof("/bridge/topology_change_timer") + 8];
|
||||||
|
@ -490,7 +468,24 @@ static void show_bridge_stp(const char *name)
|
||||||
printf("TOPOLOGY_CHANGE_DETECTED ");
|
printf("TOPOLOGY_CHANGE_DETECTED ");
|
||||||
printf("\n\n\n");
|
printf("\n\n\n");
|
||||||
|
|
||||||
show_bridge_ports(name);
|
/* Show bridge ports */
|
||||||
|
{
|
||||||
|
DIR *ifaces;
|
||||||
|
|
||||||
|
/* sfx points past "BR/bridge/", turn it to "BR/brif": */
|
||||||
|
strcpy(sfx - 4, "f");
|
||||||
|
ifaces = opendir(pathbuf);
|
||||||
|
if (ifaces) {
|
||||||
|
struct dirent *ent;
|
||||||
|
while ((ent = readdir(ifaces)) != NULL) {
|
||||||
|
if (DOT_OR_DOTDOT(ent->d_name))
|
||||||
|
continue; /* . or .. */
|
||||||
|
show_bridge_port(ent->d_name);
|
||||||
|
}
|
||||||
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
|
closedir(ifaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -519,6 +514,8 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
)
|
)
|
||||||
IF_FEATURE_BRCTL_SHOW(, ARG_show)
|
IF_FEATURE_BRCTL_SHOW(, ARG_show)
|
||||||
};
|
};
|
||||||
|
int key;
|
||||||
|
char *br;
|
||||||
|
|
||||||
argv++;
|
argv++;
|
||||||
if (!*argv) {
|
if (!*argv) {
|
||||||
|
@ -528,11 +525,6 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
|
|
||||||
xchdir("/sys/class/net");
|
xchdir("/sys/class/net");
|
||||||
|
|
||||||
// while (*argv)
|
|
||||||
{
|
|
||||||
smallint key;
|
|
||||||
char *br;
|
|
||||||
|
|
||||||
key = index_in_strings(keywords, *argv);
|
key = index_in_strings(keywords, *argv);
|
||||||
if (key == -1) /* no match found in keywords array, bail out. */
|
if (key == -1) /* no match found in keywords array, bail out. */
|
||||||
bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
|
bb_error_msg_and_die(bb_msg_invalid_arg_to, *argv, applet_name);
|
||||||
|
@ -580,7 +572,6 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
br = *argv++;
|
br = *argv++;
|
||||||
|
|
||||||
if (key == ARG_addbr || key == ARG_delbr) {
|
if (key == ARG_addbr || key == ARG_delbr) {
|
||||||
/* addbr or delbr */
|
|
||||||
/* brctl from bridge-utils 1.6 still uses ioctl
|
/* brctl from bridge-utils 1.6 still uses ioctl
|
||||||
* for SIOCBRADDBR / SIOCBRDELBR, not /sys accesses
|
* for SIOCBRADDBR / SIOCBRDELBR, not /sys accesses
|
||||||
*/
|
*/
|
||||||
|
@ -612,7 +603,7 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
#if ENABLE_FEATURE_BRCTL_FANCY
|
#if ENABLE_FEATURE_BRCTL_FANCY
|
||||||
if (key == ARG_stp) { /* stp */
|
if (key == ARG_stp) {
|
||||||
static const char no_yes[] ALIGN1 =
|
static const char no_yes[] ALIGN1 =
|
||||||
"0\0" "off\0" "n\0" "no\0" /* 0 .. 3 */
|
"0\0" "off\0" "n\0" "no\0" /* 0 .. 3 */
|
||||||
"1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
|
"1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
|
||||||
|
@ -671,7 +662,6 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* always true: if (key == ARG_addif || key == ARG_delif) */ {
|
/* always true: if (key == ARG_addif || key == ARG_delif) */ {
|
||||||
/* addif or delif */
|
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd = xsocket(AF_INET, SOCK_STREAM, 0);
|
int fd = xsocket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
|
||||||
|
@ -686,8 +676,6 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
||||||
);
|
);
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
close(fd);
|
close(fd);
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue