* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: ifconfig.c,v 1.7 2001/03/10 02:00:54 mjn3 Exp $
+ * $Id: ifconfig.c,v 1.10 2001/03/26 16:26:16 mjn3 Exp $
*
*/
* converting to a table-driven approach. Added several (optional)
* args missing from initial port.
*
- * Still missing: media.
+ * Still missing: media, tunnel.
*/
#include <stdio.h>
#endif
#ifdef BB_FEATURE_IFCONFIG_STATUS
-extern int display_interfaces(int display_all);
+extern int interface_opt_a;
+extern int display_interfaces(char *ifname);
#endif
/*
goterr = 0;
did_flags = 0;
- if(argc < 2) {
-#ifdef BB_FEATURE_IFCONFIG_STATUS
- return(display_interfaces(0));
-#else
- show_usage();
-#endif
- }
-
/* skip argv[0] */
- argc--;
- argv++;
+ ++argv;
+ --argc;
#ifdef BB_FEATURE_IFCONFIG_STATUS
- if ((argc == 1) && (strcmp(*argv, "-a") == 0)) {
- return(display_interfaces(1));
+ if ((argc > 0) && (strcmp(*argv,"-a") == 0)) {
+ interface_opt_a = 1;
+ --argc;
+ ++argv;
}
#endif
+ if(argc <= 1) {
+#ifdef BB_FEATURE_IFCONFIG_STATUS
+ return display_interfaces(argc ? *argv : NULL);
+#else
+ error_msg_and_die( "ifconfig was not compiled with interface status display support.");
+#endif
+ }
+
/* Create a channel to the NET kernel. */
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror_msg_and_die("socket");
if (c >= '0' && c <= '9') {
c -= '0';
} else if (c >= 'a' && c <= 'f') {
- c -= ('a' + 10);
+ c -= ('a' - 10);
} else if (c >= 'A' && c <= 'F') {
- c -= ('A' + 10);
+ c -= ('A' - 10);
} else if (j && (c == ':' || c == 0)) {
break;
} else {