Quick mod to enable option -a for ifconfig.
This commit is contained in:
parent
d2117e9c82
commit
78f57460f2
22
ifconfig.c
22
ifconfig.c
@ -15,7 +15,7 @@
|
|||||||
* Foundation; either version 2 of the License, or (at
|
* Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* $Id: ifconfig.c,v 1.6 2001/03/09 23:06:15 mjn3 Exp $
|
* $Id: ifconfig.c,v 1.7 2001/03/10 02:00:54 mjn3 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ static int in_ether(char *bufp, struct sockaddr *sap);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
extern int display_interfaces(void);
|
extern int display_interfaces(int display_all);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -263,21 +263,27 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
return(display_interfaces());
|
return(display_interfaces(0));
|
||||||
#else
|
#else
|
||||||
show_usage();
|
show_usage();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skip argv[0] */
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
|
if ((argc == 1) && (strcmp(*argv, "-a") == 0)) {
|
||||||
|
return(display_interfaces(1));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create a channel to the NET kernel. */
|
/* Create a channel to the NET kernel. */
|
||||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||||
perror_msg_and_die("socket");
|
perror_msg_and_die("socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip argv[0] */
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
/* get interface name */
|
/* get interface name */
|
||||||
safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
|
safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
|
||||||
|
|
||||||
@ -290,7 +296,7 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
mask = M_MASK; /* set the appropriate mask. */
|
mask = M_MASK; /* set the appropriate mask. */
|
||||||
}
|
}
|
||||||
for (op = OptArray ; op->name ; op++) { /* Find table entry. */
|
for (op = OptArray ; op->name ; op++) { /* Find table entry. */
|
||||||
if (!strcmp(p,op->name)) { /* If name matches... */
|
if (strcmp(p,op->name) == 0) { /* If name matches... */
|
||||||
if ((mask &= op->flags)) { /* set the mask and go. */
|
if ((mask &= op->flags)) { /* set the mask and go. */
|
||||||
goto FOUND_ARG;;
|
goto FOUND_ARG;;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* that either displays or sets the characteristics of
|
* that either displays or sets the characteristics of
|
||||||
* one or more of the system's networking interfaces.
|
* one or more of the system's networking interfaces.
|
||||||
*
|
*
|
||||||
* Version: $Id: interface.c,v 1.2 2001/03/06 20:54:43 andersen Exp $
|
* Version: $Id: interface.c,v 1.3 2001/03/10 02:00:54 mjn3 Exp $
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
||||||
* and others. Copyright 1993 MicroWalt Corporation
|
* and others. Copyright 1993 MicroWalt Corporation
|
||||||
@ -2059,14 +2059,15 @@ static int if_print(char *ifname)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int display_interfaces(void)
|
int display_interfaces(int opt_all)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
opt_a = opt_all;
|
||||||
|
|
||||||
/* Create a channel to the NET kernel. */
|
/* Create a channel to the NET kernel. */
|
||||||
if ((skfd = sockets_open(0)) < 0) {
|
if ((skfd = sockets_open(0)) < 0) {
|
||||||
perror("socket");
|
perror_msg_and_die("socket");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we have to show the current setup? */
|
/* Do we have to show the current setup? */
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* Foundation; either version 2 of the License, or (at
|
* Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* $Id: ifconfig.c,v 1.6 2001/03/09 23:06:15 mjn3 Exp $
|
* $Id: ifconfig.c,v 1.7 2001/03/10 02:00:54 mjn3 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ static int in_ether(char *bufp, struct sockaddr *sap);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
extern int display_interfaces(void);
|
extern int display_interfaces(int display_all);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -263,21 +263,27 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
return(display_interfaces());
|
return(display_interfaces(0));
|
||||||
#else
|
#else
|
||||||
show_usage();
|
show_usage();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* skip argv[0] */
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
|
||||||
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
|
if ((argc == 1) && (strcmp(*argv, "-a") == 0)) {
|
||||||
|
return(display_interfaces(1));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create a channel to the NET kernel. */
|
/* Create a channel to the NET kernel. */
|
||||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||||
perror_msg_and_die("socket");
|
perror_msg_and_die("socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip argv[0] */
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
/* get interface name */
|
/* get interface name */
|
||||||
safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
|
safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
|
||||||
|
|
||||||
@ -290,7 +296,7 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
mask = M_MASK; /* set the appropriate mask. */
|
mask = M_MASK; /* set the appropriate mask. */
|
||||||
}
|
}
|
||||||
for (op = OptArray ; op->name ; op++) { /* Find table entry. */
|
for (op = OptArray ; op->name ; op++) { /* Find table entry. */
|
||||||
if (!strcmp(p,op->name)) { /* If name matches... */
|
if (strcmp(p,op->name) == 0) { /* If name matches... */
|
||||||
if ((mask &= op->flags)) { /* set the mask and go. */
|
if ((mask &= op->flags)) { /* set the mask and go. */
|
||||||
goto FOUND_ARG;;
|
goto FOUND_ARG;;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user