mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 16:31:24 +00:00
Reduced code size of interface. Support ifconfig -a and ifconfig interface
display. Change %llu to %Lu in ifconfig for hacked unsigned long long support in uClibc scanf.
This commit is contained in:
parent
1365bb7861
commit
68ea1d0325
33
ifconfig.c
33
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.7 2001/03/10 02:00:54 mjn3 Exp $
|
* $Id: ifconfig.c,v 1.8 2001/03/12 09:57:59 mjn3 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* converting to a table-driven approach. Added several (optional)
|
* converting to a table-driven approach. Added several (optional)
|
||||||
* args missing from initial port.
|
* args missing from initial port.
|
||||||
*
|
*
|
||||||
* Still missing: media.
|
* Still missing: media, tunnel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -234,7 +234,8 @@ 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(int display_all);
|
extern int interface_opt_a;
|
||||||
|
extern int display_interfaces(char *ifname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -261,24 +262,26 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
goterr = 0;
|
goterr = 0;
|
||||||
did_flags = 0;
|
did_flags = 0;
|
||||||
|
|
||||||
if(argc < 2) {
|
/* skip argv[0] */
|
||||||
|
++argv;
|
||||||
|
--argc;
|
||||||
|
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
return(display_interfaces(0));
|
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
|
#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");
|
||||||
|
282
interface.c
282
interface.c
@ -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.3 2001/03/10 02:00:54 mjn3 Exp $
|
* Version: $Id: interface.c,v 1.4 2001/03/12 09:57:59 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
|
||||||
@ -26,6 +26,17 @@
|
|||||||
* Erik Andersen <andersee@debian.org>
|
* Erik Andersen <andersee@debian.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Heavily modified by Manuel Novoa III Mar 12, 2001
|
||||||
|
*
|
||||||
|
* Pruned unused code using KEEP_UNUSED define.
|
||||||
|
* Added print_bytes_scaled function to reduce code size.
|
||||||
|
* Added some (potentially) missing defines.
|
||||||
|
* Improved display support for -a and for a named interface.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* #define KEEP_UNUSED */
|
||||||
|
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -75,7 +86,7 @@
|
|||||||
#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
|
#define new(p) ((p) = xcalloc(1,sizeof(*(p))))
|
||||||
#define KRELEASE(maj,min,patch) ((maj) * 10000 + (min)*1000 + (patch))
|
#define KRELEASE(maj,min,patch) ((maj) * 10000 + (min)*1000 + (patch))
|
||||||
|
|
||||||
int procnetdev_vsn = 1;
|
static int procnetdev_vsn = 1;
|
||||||
|
|
||||||
|
|
||||||
/* Ugh. But libc5 doesn't provide POSIX types. */
|
/* Ugh. But libc5 doesn't provide POSIX types. */
|
||||||
@ -120,10 +131,29 @@ struct in6_ifreq {
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Defines for glibc2.0 users. */
|
||||||
|
#ifndef SIOCSIFTXQLEN
|
||||||
|
#define SIOCSIFTXQLEN 0x8943
|
||||||
|
#define SIOCGIFTXQLEN 0x8942
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ifr_qlen is ifru_ivalue, but it isn't present in 2.0 kernel headers */
|
||||||
|
#ifndef ifr_qlen
|
||||||
|
#define ifr_qlen ifr_ifru.ifru_mtu
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_TXQUEUELEN
|
||||||
|
#define HAVE_TXQUEUELEN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IFF_DYNAMIC
|
||||||
|
#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This structure defines protocol families and their handlers. */
|
/* This structure defines protocol families and their handlers. */
|
||||||
struct aftype {
|
struct aftype {
|
||||||
char *name;
|
const char *name;
|
||||||
char *title;
|
const char *title;
|
||||||
int af;
|
int af;
|
||||||
int alen;
|
int alen;
|
||||||
char *(*print) (unsigned char *);
|
char *(*print) (unsigned char *);
|
||||||
@ -140,20 +170,23 @@ struct aftype {
|
|||||||
char *flag_file;
|
char *flag_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct aftype *aftypes[];
|
static struct aftype *aftypes[];
|
||||||
int flag_unx;
|
|
||||||
int flag_ipx;
|
#ifdef KEEP_UNUSED
|
||||||
int flag_ax25;
|
|
||||||
int flag_ddp;
|
static int flag_unx;
|
||||||
int flag_netrom;
|
static int flag_ipx;
|
||||||
int flag_inet;
|
static int flag_ax25;
|
||||||
int flag_inet6;
|
static int flag_ddp;
|
||||||
int flag_econet;
|
static int flag_netrom;
|
||||||
int flag_x25 = 0;
|
static int flag_inet;
|
||||||
int flag_ash;
|
static int flag_inet6;
|
||||||
|
static int flag_econet;
|
||||||
|
static int flag_x25 = 0;
|
||||||
|
static int flag_ash;
|
||||||
|
|
||||||
|
|
||||||
struct aftrans_t {
|
static struct aftrans_t {
|
||||||
char *alias;
|
char *alias;
|
||||||
char *name;
|
char *name;
|
||||||
int *flag;
|
int *flag;
|
||||||
@ -206,7 +239,8 @@ struct aftrans_t {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
char afname[256] = "";
|
static char afname[256] = "";
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
#if HAVE_AFUNIX
|
#if HAVE_AFUNIX
|
||||||
|
|
||||||
@ -228,9 +262,9 @@ static char *UNIX_sprint(struct sockaddr *sap, int numeric)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct aftype unix_aftype =
|
static struct aftype unix_aftype =
|
||||||
{
|
{
|
||||||
"unix", NULL, /*"UNIX Domain", */ AF_UNIX, 0,
|
"unix", "UNIX Domain", AF_UNIX, 0,
|
||||||
UNIX_print, UNIX_sprint, NULL, NULL,
|
UNIX_print, UNIX_sprint, NULL, NULL,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
-1,
|
-1,
|
||||||
@ -240,7 +274,9 @@ struct aftype unix_aftype =
|
|||||||
|
|
||||||
#if HAVE_AFINET
|
#if HAVE_AFINET
|
||||||
|
|
||||||
|
#if 0
|
||||||
extern int h_errno; /* some netdb.h versions don't export this */
|
extern int h_errno; /* some netdb.h versions don't export this */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* cache */
|
/* cache */
|
||||||
struct addr {
|
struct addr {
|
||||||
@ -252,6 +288,7 @@ struct addr {
|
|||||||
|
|
||||||
static struct addr *INET_nn = NULL; /* addr-to-name cache */
|
static struct addr *INET_nn = NULL; /* addr-to-name cache */
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst)
|
static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst)
|
||||||
{
|
{
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
@ -310,7 +347,7 @@ static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
/* numeric: & 0x8000: default instead of *,
|
/* numeric: & 0x8000: default instead of *,
|
||||||
* & 0x4000: host instead of net,
|
* & 0x4000: host instead of net,
|
||||||
@ -399,19 +436,18 @@ static int INET_rresolve(char *name, size_t len, struct sockaddr_in *sin,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
static void INET_reserror(char *text)
|
static void INET_reserror(char *text)
|
||||||
{
|
{
|
||||||
herror(text);
|
herror(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Display an Internet socket address. */
|
/* Display an Internet socket address. */
|
||||||
static char *INET_print(unsigned char *ptr)
|
static char *INET_print(unsigned char *ptr)
|
||||||
{
|
{
|
||||||
return (inet_ntoa((*(struct in_addr *) ptr)));
|
return (inet_ntoa((*(struct in_addr *) ptr)));
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
/* Display an Internet socket address. */
|
/* Display an Internet socket address. */
|
||||||
static char *INET_sprint(struct sockaddr *sap, int numeric)
|
static char *INET_sprint(struct sockaddr *sap, int numeric)
|
||||||
@ -428,7 +464,8 @@ static char *INET_sprint(struct sockaddr *sap, int numeric)
|
|||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *INET_sprintmask(struct sockaddr *sap, int numeric,
|
#ifdef KEEP_UNUSED
|
||||||
|
static char *INET_sprintmask(struct sockaddr *sap, int numeric,
|
||||||
unsigned int netmask)
|
unsigned int netmask)
|
||||||
{
|
{
|
||||||
static char buff[128];
|
static char buff[128];
|
||||||
@ -441,7 +478,6 @@ char *INET_sprintmask(struct sockaddr *sap, int numeric,
|
|||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int INET_getsock(char *bufp, struct sockaddr *sap)
|
static int INET_getsock(char *bufp, struct sockaddr *sap)
|
||||||
{
|
{
|
||||||
char *sp = bufp, *bp;
|
char *sp = bufp, *bp;
|
||||||
@ -516,14 +552,15 @@ static int INET_getnetmask(char *adr, struct sockaddr *m, char *name)
|
|||||||
mask->sin_addr.s_addr = htonl(~(0xffffffffU >> prefix));
|
mask->sin_addr.s_addr = htonl(~(0xffffffffU >> prefix));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
|
static struct aftype inet_aftype =
|
||||||
struct aftype inet_aftype =
|
|
||||||
{
|
{
|
||||||
"inet", NULL, /*"DARPA Internet", */ AF_INET, sizeof(unsigned long),
|
"inet", "DARPA Internet", AF_INET, sizeof(unsigned long),
|
||||||
INET_print, INET_sprint, INET_input, INET_reserror,
|
NULL /* UNUSED INET_print */, INET_sprint,
|
||||||
|
NULL /* UNUSED INET_input */, NULL /* UNUSED INET_reserror */,
|
||||||
NULL /*INET_rprint */ , NULL /*INET_rinput */ ,
|
NULL /*INET_rprint */ , NULL /*INET_rinput */ ,
|
||||||
INET_getnetmask,
|
NULL /* UNUSED INET_getnetmask */,
|
||||||
-1,
|
-1,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
@ -555,16 +592,14 @@ static char *UNSPEC_sprint(struct sockaddr *sap, int numeric)
|
|||||||
return (UNSPEC_print(sap->sa_data));
|
return (UNSPEC_print(sap->sa_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct aftype unspec_aftype =
|
static struct aftype unspec_aftype =
|
||||||
{
|
{
|
||||||
"unspec", NULL, /*"UNSPEC", */ AF_UNSPEC, 0,
|
"unspec", "UNSPEC", AF_UNSPEC, 0,
|
||||||
UNSPEC_print, UNSPEC_sprint, NULL, NULL,
|
UNSPEC_print, UNSPEC_sprint, NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static short sVafinit = 0;
|
static struct aftype *aftypes[] =
|
||||||
|
|
||||||
struct aftype *aftypes[] =
|
|
||||||
{
|
{
|
||||||
#if HAVE_AFUNIX
|
#if HAVE_AFUNIX
|
||||||
&unix_aftype,
|
&unix_aftype,
|
||||||
@ -603,7 +638,10 @@ struct aftype *aftypes[] =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
void afinit()
|
#ifdef KEEP_UNUSED
|
||||||
|
static short sVafinit = 0;
|
||||||
|
|
||||||
|
static void afinit()
|
||||||
{
|
{
|
||||||
unspec_aftype.title = _("UNSPEC");
|
unspec_aftype.title = _("UNSPEC");
|
||||||
#if HAVE_AFUNIX
|
#if HAVE_AFUNIX
|
||||||
@ -642,7 +680,7 @@ void afinit()
|
|||||||
sVafinit = 1;
|
sVafinit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aftrans_opt(const char *arg)
|
static int aftrans_opt(const char *arg)
|
||||||
{
|
{
|
||||||
struct aftrans_t *paft;
|
struct aftrans_t *paft;
|
||||||
char *tmp1, *tmp2;
|
char *tmp1, *tmp2;
|
||||||
@ -685,7 +723,7 @@ int aftrans_opt(const char *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set the default AF list from the program name or a constant value */
|
/* set the default AF list from the program name or a constant value */
|
||||||
void aftrans_def(char *tool, char *argv0, char *dflt)
|
static void aftrans_def(char *tool, char *argv0, char *dflt)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -721,14 +759,15 @@ void aftrans_def(char *tool, char *argv0, char *dflt)
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Check our protocol family table for this family. */
|
/* Check our protocol family table for this family. */
|
||||||
struct aftype *get_aftype(const char *name)
|
static struct aftype *get_aftype(const char *name)
|
||||||
{
|
{
|
||||||
struct aftype **afp;
|
struct aftype **afp;
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
if (!sVafinit)
|
if (!sVafinit)
|
||||||
afinit();
|
afinit();
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
afp = aftypes;
|
afp = aftypes;
|
||||||
while (*afp != NULL) {
|
while (*afp != NULL) {
|
||||||
@ -740,15 +779,17 @@ struct aftype *get_aftype(const char *name)
|
|||||||
fprintf(stderr, _("Please don't supply more than one address family.\n"));
|
fprintf(stderr, _("Please don't supply more than one address family.\n"));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
/* Check our protocol family table for this family. */
|
/* Check our protocol family table for this family. */
|
||||||
struct aftype *get_afntype(int af)
|
static struct aftype *get_afntype(int af)
|
||||||
{
|
{
|
||||||
struct aftype **afp;
|
struct aftype **afp;
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
if (!sVafinit)
|
if (!sVafinit)
|
||||||
afinit();
|
afinit();
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
afp = aftypes;
|
afp = aftypes;
|
||||||
while (*afp != NULL) {
|
while (*afp != NULL) {
|
||||||
@ -760,12 +801,14 @@ struct aftype *get_afntype(int af)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check our protocol family table for this family and return its socket */
|
/* Check our protocol family table for this family and return its socket */
|
||||||
int get_socket_for_af(int af)
|
static int get_socket_for_af(int af)
|
||||||
{
|
{
|
||||||
struct aftype **afp;
|
struct aftype **afp;
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
if (!sVafinit)
|
if (!sVafinit)
|
||||||
afinit();
|
afinit();
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
afp = aftypes;
|
afp = aftypes;
|
||||||
while (*afp != NULL) {
|
while (*afp != NULL) {
|
||||||
@ -776,14 +819,17 @@ int get_socket_for_af(int af)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
/* type: 0=all, 1=getroute */
|
/* type: 0=all, 1=getroute */
|
||||||
void print_aflist(int type) {
|
static void print_aflist(int type) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char * txt;
|
char * txt;
|
||||||
struct aftype **afp;
|
struct aftype **afp;
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
if (!sVafinit)
|
if (!sVafinit)
|
||||||
afinit();
|
afinit();
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
afp = aftypes;
|
afp = aftypes;
|
||||||
while (*afp != NULL) {
|
while (*afp != NULL) {
|
||||||
@ -792,12 +838,13 @@ void print_aflist(int type) {
|
|||||||
}
|
}
|
||||||
if ((count % 3) == 0) fprintf(stderr,count?"\n ":" ");
|
if ((count % 3) == 0) fprintf(stderr,count?"\n ":" ");
|
||||||
txt = (*afp)->name; if (!txt) txt = "..";
|
txt = (*afp)->name; if (!txt) txt = "..";
|
||||||
fprintf(stderr,"%s (%s) ",txt,(*afp)->title);
|
fprintf(stderr,"%s (%s) ",txt,_((*afp)->title));
|
||||||
count++;
|
count++;
|
||||||
afp++;
|
afp++;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"\n");
|
fprintf(stderr,"\n");
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
struct user_net_device_stats {
|
struct user_net_device_stats {
|
||||||
unsigned long long rx_packets; /* total packets received */
|
unsigned long long rx_packets; /* total packets received */
|
||||||
@ -863,16 +910,20 @@ struct interface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int opt_a = 0; /* show all interfaces */
|
int interface_opt_a = 0; /* show all interfaces */
|
||||||
int opt_i = 0; /* show the statistics */
|
|
||||||
int opt_v = 0; /* debugging output flag */
|
#ifdef KEEP_UNUSED
|
||||||
|
static int opt_i = 0; /* show the statistics */
|
||||||
|
static int opt_v = 0; /* debugging output flag */
|
||||||
|
|
||||||
|
static int addr_family = 0; /* currently selected AF */
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
int addr_family = 0; /* currently selected AF */
|
|
||||||
static struct interface *int_list, *int_last;
|
static struct interface *int_list, *int_last;
|
||||||
int skfd = -1; /* generic raw socket desc. */
|
static int skfd = -1; /* generic raw socket desc. */
|
||||||
|
|
||||||
|
|
||||||
int sockets_open(int family)
|
static int sockets_open(int family)
|
||||||
{
|
{
|
||||||
struct aftype **aft;
|
struct aftype **aft;
|
||||||
int sfd = -1;
|
int sfd = -1;
|
||||||
@ -919,7 +970,7 @@ int sockets_open(int family)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* like strcmp(), but knows about numbers */
|
/* like strcmp(), but knows about numbers */
|
||||||
int nstrcmp(const char *astr, const char *b)
|
static int nstrcmp(const char *astr, const char *b)
|
||||||
{
|
{
|
||||||
const char *a = astr;
|
const char *a = astr;
|
||||||
|
|
||||||
@ -1053,7 +1104,7 @@ static int get_dev_fields(char *bp, struct interface *ife)
|
|||||||
switch (procnetdev_vsn) {
|
switch (procnetdev_vsn) {
|
||||||
case 3:
|
case 3:
|
||||||
sscanf(bp,
|
sscanf(bp,
|
||||||
"%llu %llu %lu %lu %lu %lu %lu %lu %llu %llu %lu %lu %lu %lu %lu %lu",
|
"%Lu %Lu %lu %lu %lu %lu %lu %lu %Lu %Lu %lu %lu %lu %lu %lu %lu",
|
||||||
&ife->stats.rx_bytes,
|
&ife->stats.rx_bytes,
|
||||||
&ife->stats.rx_packets,
|
&ife->stats.rx_packets,
|
||||||
&ife->stats.rx_errors,
|
&ife->stats.rx_errors,
|
||||||
@ -1073,7 +1124,7 @@ static int get_dev_fields(char *bp, struct interface *ife)
|
|||||||
&ife->stats.tx_compressed);
|
&ife->stats.tx_compressed);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sscanf(bp, "%llu %llu %lu %lu %lu %lu %llu %llu %lu %lu %lu %lu %lu",
|
sscanf(bp, "%Lu %Lu %lu %lu %lu %lu %Lu %Lu %lu %lu %lu %lu %lu",
|
||||||
&ife->stats.rx_bytes,
|
&ife->stats.rx_bytes,
|
||||||
&ife->stats.rx_packets,
|
&ife->stats.rx_packets,
|
||||||
&ife->stats.rx_errors,
|
&ife->stats.rx_errors,
|
||||||
@ -1091,7 +1142,7 @@ static int get_dev_fields(char *bp, struct interface *ife)
|
|||||||
ife->stats.rx_multicast = 0;
|
ife->stats.rx_multicast = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sscanf(bp, "%llu %lu %lu %lu %lu %llu %lu %lu %lu %lu %lu",
|
sscanf(bp, "%Lu %lu %lu %lu %lu %Lu %lu %lu %lu %lu %lu",
|
||||||
&ife->stats.rx_packets,
|
&ife->stats.rx_packets,
|
||||||
&ife->stats.rx_errors,
|
&ife->stats.rx_errors,
|
||||||
&ife->stats.rx_dropped,
|
&ife->stats.rx_dropped,
|
||||||
@ -1112,7 +1163,7 @@ static int get_dev_fields(char *bp, struct interface *ife)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int procnetdev_version(char *buf)
|
static inline int procnetdev_version(char *buf)
|
||||||
{
|
{
|
||||||
if (strstr(buf, "compressed"))
|
if (strstr(buf, "compressed"))
|
||||||
return 3;
|
return 3;
|
||||||
@ -1192,7 +1243,7 @@ static int if_readlist_proc(char *target)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int if_readlist(void)
|
static int if_readlist(void)
|
||||||
{
|
{
|
||||||
int err = if_readlist_proc(NULL);
|
int err = if_readlist_proc(NULL);
|
||||||
if (!err)
|
if (!err)
|
||||||
@ -1200,7 +1251,7 @@ int if_readlist(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int for_all_interfaces(int (*doit) (struct interface *, void *), void *cookie)
|
static int for_all_interfaces(int (*doit) (struct interface *, void *), void *cookie)
|
||||||
{
|
{
|
||||||
struct interface *ife;
|
struct interface *ife;
|
||||||
|
|
||||||
@ -1226,7 +1277,7 @@ static int ipx_getaddr(int sock, int ft, struct ifreq *ifr)
|
|||||||
|
|
||||||
|
|
||||||
/* Fetch the interface configuration from the kernel. */
|
/* Fetch the interface configuration from the kernel. */
|
||||||
int if_fetch(struct interface *ife)
|
static int if_fetch(struct interface *ife)
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd;
|
int fd;
|
||||||
@ -1386,7 +1437,7 @@ int if_fetch(struct interface *ife)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_if_fetch(struct interface *ife)
|
static int do_if_fetch(struct interface *ife)
|
||||||
{
|
{
|
||||||
if (if_fetch(ife) < 0) {
|
if (if_fetch(ife) < 0) {
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
@ -1405,8 +1456,8 @@ int do_if_fetch(struct interface *ife)
|
|||||||
|
|
||||||
/* This structure defines hardware protocols and their handlers. */
|
/* This structure defines hardware protocols and their handlers. */
|
||||||
struct hwtype {
|
struct hwtype {
|
||||||
char *name;
|
const char *name;
|
||||||
char *title;
|
const char *title;
|
||||||
int type;
|
int type;
|
||||||
int alen;
|
int alen;
|
||||||
char *(*print) (unsigned char *);
|
char *(*print) (unsigned char *);
|
||||||
@ -1430,15 +1481,15 @@ static char *pr_unspec(unsigned char *ptr)
|
|||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hwtype unspec_hwtype =
|
static struct hwtype unspec_hwtype =
|
||||||
{
|
{
|
||||||
"unspec", NULL, /*"UNSPEC", */ -1, 0,
|
"unspec", "UNSPEC", -1, 0,
|
||||||
pr_unspec, NULL, NULL
|
pr_unspec, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hwtype loop_hwtype =
|
static struct hwtype loop_hwtype =
|
||||||
{
|
{
|
||||||
"loop", NULL, /*"Local Loopback", */ ARPHRD_LOOPBACK, 0,
|
"loop", "Local Loopback", ARPHRD_LOOPBACK, 0,
|
||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1446,7 +1497,7 @@ struct hwtype loop_hwtype =
|
|||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
|
|
||||||
extern struct hwtype ether_hwtype;
|
static struct hwtype ether_hwtype;
|
||||||
|
|
||||||
/* Display an Ethernet address in readable format. */
|
/* Display an Ethernet address in readable format. */
|
||||||
static char *pr_ether(unsigned char *ptr)
|
static char *pr_ether(unsigned char *ptr)
|
||||||
@ -1460,7 +1511,7 @@ static char *pr_ether(unsigned char *ptr)
|
|||||||
return (buff);
|
return (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
/* Input an Ethernet address and convert to binary. */
|
/* Input an Ethernet address and convert to binary. */
|
||||||
static int in_ether(char *bufp, struct sockaddr *sap)
|
static int in_ether(char *bufp, struct sockaddr *sap)
|
||||||
{
|
{
|
||||||
@ -1539,12 +1590,13 @@ static int in_ether(char *bufp, struct sockaddr *sap)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
|
|
||||||
struct hwtype ether_hwtype =
|
static struct hwtype ether_hwtype =
|
||||||
{
|
{
|
||||||
"ether", NULL, /*"10Mbps Ethernet", */ ARPHRD_ETHER, ETH_ALEN,
|
"ether", "Ethernet", ARPHRD_ETHER, ETH_ALEN,
|
||||||
pr_ether, in_ether, NULL
|
pr_ether, NULL /* UNUSED in_ether */, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1555,18 +1607,19 @@ struct hwtype ether_hwtype =
|
|||||||
|
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
/* Start the PPP encapsulation on the file descriptor. */
|
/* Start the PPP encapsulation on the file descriptor. */
|
||||||
static int do_ppp(int fd)
|
static int do_ppp(int fd)
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("You cannot start PPP with this program.\n"));
|
fprintf(stderr, _("You cannot start PPP with this program.\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
|
static struct hwtype ppp_hwtype =
|
||||||
struct hwtype ppp_hwtype =
|
|
||||||
{
|
{
|
||||||
"ppp", NULL, /*"Point-Point Protocol", */ ARPHRD_PPP, 0,
|
"ppp", "Point-Point Protocol", ARPHRD_PPP, 0,
|
||||||
NULL, NULL, do_ppp, 0
|
NULL, NULL, NULL /* UNUSED do_ppp */, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1647,9 +1700,10 @@ static struct hwtype *hwtypes[] =
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
static short sVhwinit = 0;
|
static short sVhwinit = 0;
|
||||||
|
|
||||||
void hwinit()
|
static void hwinit()
|
||||||
{
|
{
|
||||||
loop_hwtype.title = _("Local Loopback");
|
loop_hwtype.title = _("Local Loopback");
|
||||||
unspec_hwtype.title = _("UNSPEC");
|
unspec_hwtype.title = _("UNSPEC");
|
||||||
@ -1718,9 +1772,10 @@ void hwinit()
|
|||||||
#endif
|
#endif
|
||||||
sVhwinit = 1;
|
sVhwinit = 1;
|
||||||
}
|
}
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
#ifdef IFF_PORTSEL
|
#ifdef IFF_PORTSEL
|
||||||
const char *if_port_text[][4] =
|
static const char *if_port_text[][4] =
|
||||||
{
|
{
|
||||||
/* Keep in step with <linux/netdevice.h> */
|
/* Keep in step with <linux/netdevice.h> */
|
||||||
{"unknown", NULL, NULL, NULL},
|
{"unknown", NULL, NULL, NULL},
|
||||||
@ -1735,12 +1790,14 @@ const char *if_port_text[][4] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check our hardware type table for this type. */
|
/* Check our hardware type table for this type. */
|
||||||
struct hwtype *get_hwntype(int type)
|
static struct hwtype *get_hwntype(int type)
|
||||||
{
|
{
|
||||||
struct hwtype **hwp;
|
struct hwtype **hwp;
|
||||||
|
|
||||||
|
#ifdef KEEP_UNUSED
|
||||||
if (!sVhwinit)
|
if (!sVhwinit)
|
||||||
hwinit();
|
hwinit();
|
||||||
|
#endif /* KEEP_UNUSED */
|
||||||
|
|
||||||
hwp = hwtypes;
|
hwp = hwtypes;
|
||||||
while (*hwp != NULL) {
|
while (*hwp != NULL) {
|
||||||
@ -1752,7 +1809,7 @@ struct hwtype *get_hwntype(int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return 1 if address is all zeros */
|
/* return 1 if address is all zeros */
|
||||||
int hw_null_address(struct hwtype *hw, void *ap)
|
static int hw_null_address(struct hwtype *hw, void *ap)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned char *address = (unsigned char *)ap;
|
unsigned char *address = (unsigned char *)ap;
|
||||||
@ -1762,15 +1819,35 @@ int hw_null_address(struct hwtype *hw, void *ap)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ife_print(struct interface *ptr)
|
static const char TRext[] = "\0\0k\0M";
|
||||||
|
|
||||||
|
static void print_bytes_scaled(unsigned long long ull, const char *end)
|
||||||
|
{
|
||||||
|
unsigned long long int_part;
|
||||||
|
unsigned long frac_part;
|
||||||
|
const char *ext;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
frac_part = 0;
|
||||||
|
ext = TRext;
|
||||||
|
int_part = ull;
|
||||||
|
for (i=0 ; i<2 ; i++) {
|
||||||
|
if (int_part >= 1024) {
|
||||||
|
frac_part = ((int_part % 1024) * 10) / 1024;
|
||||||
|
int_part /= 1024;
|
||||||
|
ext += 2; /* Kb, Mb */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("X bytes:%Lu (%Lu.%lu %sb)%s", ull, int_part, frac_part, ext, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ife_print(struct interface *ptr)
|
||||||
{
|
{
|
||||||
struct aftype *ap;
|
struct aftype *ap;
|
||||||
struct hwtype *hw;
|
struct hwtype *hw;
|
||||||
int hf;
|
int hf;
|
||||||
int can_compress = 0;
|
int can_compress = 0;
|
||||||
unsigned long long rx, tx, short_rx, short_tx;
|
|
||||||
char Rext[5]="b";
|
|
||||||
char Text[5]="b";
|
|
||||||
|
|
||||||
#if HAVE_AFIPX
|
#if HAVE_AFIPX
|
||||||
static struct aftype *ipxtype = NULL;
|
static struct aftype *ipxtype = NULL;
|
||||||
@ -1803,7 +1880,7 @@ void ife_print(struct interface *ptr)
|
|||||||
if (hw == NULL)
|
if (hw == NULL)
|
||||||
hw = get_hwntype(-1);
|
hw = get_hwntype(-1);
|
||||||
|
|
||||||
printf(_("%-9.9s Link encap:%s "), ptr->name, hw->title);
|
printf(_("%-9.9s Link encap:%s "), ptr->name, _(hw->title));
|
||||||
/* For some hardware types (eg Ash, ATM) we don't print the
|
/* For some hardware types (eg Ash, ATM) we don't print the
|
||||||
hardware address if it's null. */
|
hardware address if it's null. */
|
||||||
if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
|
if (hw->print != NULL && (! (hw_null_address(hw, ptr->hwaddr) &&
|
||||||
@ -1965,24 +2042,14 @@ void ife_print(struct interface *ptr)
|
|||||||
*/
|
*/
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
printf(_("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
|
printf(_("RX packets:%Lu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
|
||||||
ptr->stats.rx_packets, ptr->stats.rx_errors,
|
ptr->stats.rx_packets, ptr->stats.rx_errors,
|
||||||
ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
|
ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
|
||||||
ptr->stats.rx_frame_errors);
|
ptr->stats.rx_frame_errors);
|
||||||
if (can_compress)
|
if (can_compress)
|
||||||
printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
|
printf(_(" compressed:%lu\n"), ptr->stats.rx_compressed);
|
||||||
|
|
||||||
rx = ptr->stats.rx_bytes;
|
|
||||||
tx = ptr->stats.tx_bytes;
|
|
||||||
short_rx = rx * 10;
|
|
||||||
short_tx = tx * 10;
|
|
||||||
if (rx > 1048576) { short_rx /= 1048576; strcpy(Rext, "Mb"); }
|
|
||||||
else if (rx > 1024) { short_rx /= 1024; strcpy(Rext, "Kb"); }
|
|
||||||
if (tx > 1048576) { short_tx /= 1048576; strcpy(Text, "Mb"); }
|
|
||||||
else if (tx > 1024) { short_tx /= 1024; strcpy(Text, "Kb"); }
|
|
||||||
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
printf(_("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
|
printf(_("TX packets:%Lu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
|
||||||
ptr->stats.tx_packets, ptr->stats.tx_errors,
|
ptr->stats.tx_packets, ptr->stats.tx_errors,
|
||||||
ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
|
ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
|
||||||
ptr->stats.tx_carrier_errors);
|
ptr->stats.tx_carrier_errors);
|
||||||
@ -1991,12 +2058,10 @@ void ife_print(struct interface *ptr)
|
|||||||
printf(_("compressed:%lu "), ptr->stats.tx_compressed);
|
printf(_("compressed:%lu "), ptr->stats.tx_compressed);
|
||||||
if (ptr->tx_queue_len != -1)
|
if (ptr->tx_queue_len != -1)
|
||||||
printf(_("txqueuelen:%d "), ptr->tx_queue_len);
|
printf(_("txqueuelen:%d "), ptr->tx_queue_len);
|
||||||
printf("\n ");
|
printf("\n R");
|
||||||
printf(_("RX bytes:%llu (%lu.%lu %s) TX bytes:%llu (%lu.%lu %s)\n"),
|
print_bytes_scaled(ptr->stats.rx_bytes, " T");
|
||||||
rx, (unsigned long)(short_rx / 10),
|
print_bytes_scaled(ptr->stats.rx_bytes, "\n");
|
||||||
(unsigned long)(short_rx % 10), Rext,
|
|
||||||
tx, (unsigned long)(short_tx / 10),
|
|
||||||
(unsigned long)(short_tx % 10), Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
|
if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma ||
|
||||||
@ -2018,7 +2083,7 @@ void ife_print(struct interface *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int do_if_print(struct interface *ife, void *cookie)
|
static int do_if_print(struct interface *ife, void *cookie)
|
||||||
{
|
{
|
||||||
int *opt_a = (int *) cookie;
|
int *opt_a = (int *) cookie;
|
||||||
int res;
|
int res;
|
||||||
@ -2031,7 +2096,7 @@ int do_if_print(struct interface *ife, void *cookie)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct interface *lookup_interface(char *name)
|
static struct interface *lookup_interface(char *name)
|
||||||
{
|
{
|
||||||
struct interface *ife = NULL;
|
struct interface *ife = NULL;
|
||||||
|
|
||||||
@ -2047,7 +2112,7 @@ static int if_print(char *ifname)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!ifname) {
|
if (!ifname) {
|
||||||
res = for_all_interfaces(do_if_print, &opt_a);
|
res = for_all_interfaces(do_if_print, &interface_opt_a);
|
||||||
} else {
|
} else {
|
||||||
struct interface *ife;
|
struct interface *ife;
|
||||||
|
|
||||||
@ -2059,20 +2124,17 @@ static int if_print(char *ifname)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int display_interfaces(int opt_all)
|
int display_interfaces(char *ifname)
|
||||||
{
|
{
|
||||||
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_msg_and_die("socket");
|
perror_msg_and_die("socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we have to show the current setup? */
|
/* Do we have to show the current setup? */
|
||||||
status = if_print((char *) NULL);
|
status = if_print(ifname);
|
||||||
close(skfd);
|
close(skfd);
|
||||||
exit(status < 0);
|
exit(status < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.7 2001/03/10 02:00:54 mjn3 Exp $
|
* $Id: ifconfig.c,v 1.8 2001/03/12 09:57:59 mjn3 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* converting to a table-driven approach. Added several (optional)
|
* converting to a table-driven approach. Added several (optional)
|
||||||
* args missing from initial port.
|
* args missing from initial port.
|
||||||
*
|
*
|
||||||
* Still missing: media.
|
* Still missing: media, tunnel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -234,7 +234,8 @@ 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(int display_all);
|
extern int interface_opt_a;
|
||||||
|
extern int display_interfaces(char *ifname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -261,24 +262,26 @@ int ifconfig_main(int argc, char **argv)
|
|||||||
goterr = 0;
|
goterr = 0;
|
||||||
did_flags = 0;
|
did_flags = 0;
|
||||||
|
|
||||||
if(argc < 2) {
|
/* skip argv[0] */
|
||||||
|
++argv;
|
||||||
|
--argc;
|
||||||
|
|
||||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||||
return(display_interfaces(0));
|
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
|
#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");
|
||||||
|
Loading…
Reference in New Issue
Block a user