networking/interface.c: get rid of global "smallint interface_opt_a"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@ -1367,7 +1367,7 @@ struct hwtype {
|
|||||||
int FAST_FUNC (*activate)(int fd);
|
int FAST_FUNC (*activate)(int fd);
|
||||||
int suppress_null_addr;
|
int suppress_null_addr;
|
||||||
};
|
};
|
||||||
extern smallint interface_opt_a;
|
#define IFNAME_SHOW_DOWNED_TOO ((char*)(intptr_t)1)
|
||||||
int display_interfaces(char *ifname) FAST_FUNC;
|
int display_interfaces(char *ifname) FAST_FUNC;
|
||||||
int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC;
|
int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC;
|
||||||
#if ENABLE_FEATURE_HWIB
|
#if ENABLE_FEATURE_HWIB
|
||||||
|
@ -338,6 +338,7 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
char *p;
|
char *p;
|
||||||
/*char host[128];*/
|
/*char host[128];*/
|
||||||
const char *host = NULL; /* make gcc happy */
|
const char *host = NULL; /* make gcc happy */
|
||||||
|
IF_FEATURE_IFCONFIG_STATUS(char *show_all_param;)
|
||||||
|
|
||||||
did_flags = 0;
|
did_flags = 0;
|
||||||
#if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS
|
#if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS
|
||||||
@ -349,15 +350,16 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
++argv;
|
++argv;
|
||||||
|
|
||||||
#if ENABLE_FEATURE_IFCONFIG_STATUS
|
#if ENABLE_FEATURE_IFCONFIG_STATUS
|
||||||
if (argv[0] && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) {
|
show_all_param = NULL;
|
||||||
interface_opt_a = 1;
|
if (argv[0] && argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2]) {
|
||||||
++argv;
|
++argv;
|
||||||
|
show_all_param = IFNAME_SHOW_DOWNED_TOO;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!argv[0] || !argv[1]) { /* one or no args */
|
if (!argv[0] || !argv[1]) { /* one or no args */
|
||||||
#if ENABLE_FEATURE_IFCONFIG_STATUS
|
#if ENABLE_FEATURE_IFCONFIG_STATUS
|
||||||
return display_interfaces(argv[0] /* can be NULL */);
|
return display_interfaces(argv[0] ? argv[0] : show_all_param);
|
||||||
#else
|
#else
|
||||||
bb_error_msg_and_die("no support for status display");
|
bb_error_msg_and_die("no support for status display");
|
||||||
#endif
|
#endif
|
||||||
|
@ -342,8 +342,6 @@ struct interface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
smallint interface_opt_a; /* show all interfaces */
|
|
||||||
|
|
||||||
static struct interface *int_list, *int_last;
|
static struct interface *int_list, *int_last;
|
||||||
|
|
||||||
|
|
||||||
@ -1086,13 +1084,13 @@ static void ife_print(struct interface *ptr)
|
|||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_if_print(struct interface *ife) /*, int *opt_a)*/
|
static int do_if_print(struct interface *ife, int show_downed_too)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = do_if_fetch(ife);
|
res = do_if_fetch(ife);
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
if ((ife->flags & IFF_UP) || interface_opt_a)
|
if ((ife->flags & IFF_UP) || show_downed_too)
|
||||||
ife_print(ife);
|
ife_print(ife);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@ -1128,40 +1126,33 @@ static int for_all_interfaces(int (*doit) (struct interface *, void *),
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* for ipv4 add/del modes */
|
int FAST_FUNC display_interfaces(char *ifname)
|
||||||
static int if_print(char *ifname)
|
|
||||||
{
|
{
|
||||||
struct interface *ife;
|
struct interface *ife;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!ifname) {
|
if (!ifname || ifname == IFNAME_SHOW_DOWNED_TOO) {
|
||||||
/*res = for_all_interfaces(do_if_print, &interface_opt_a);*/
|
/*res = for_all_interfaces(do_if_print, &interface_opt_a);*/
|
||||||
if (!int_list) {
|
if (!int_list) {
|
||||||
int err = if_readlist();
|
res = if_readlist();
|
||||||
if (err < 0)
|
if (res < 0)
|
||||||
return err;
|
goto ret;
|
||||||
}
|
}
|
||||||
for (ife = int_list; ife; ife = ife->next) {
|
for (ife = int_list; ife; ife = ife->next) {
|
||||||
int err = do_if_print(ife); /*, &interface_opt_a);*/
|
BUILD_BUG_ON((int)(intptr_t)IFNAME_SHOW_DOWNED_TOO != 1);
|
||||||
if (err)
|
res = do_if_print(ife, (int)(intptr_t)ifname);
|
||||||
return err;
|
if (res < 0)
|
||||||
|
goto ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ife = lookup_interface(ifname);
|
ife = lookup_interface(ifname);
|
||||||
res = do_if_fetch(ife);
|
res = do_if_fetch(ife);
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
ife_print(ife);
|
ife_print(ife);
|
||||||
return res;
|
ret:
|
||||||
}
|
return (res < 0); /* status < 0 == 1 -- error */
|
||||||
|
|
||||||
int FAST_FUNC display_interfaces(char *ifname)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
|
|
||||||
status = if_print(ifname);
|
|
||||||
|
|
||||||
return (status < 0); /* status < 0 == 1 -- error */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HWIB
|
#if ENABLE_FEATURE_HWIB
|
||||||
|
Reference in New Issue
Block a user