forked from Imagelibrary/rtems
2003-08-06 Till Strauman <strauman@slac.stanford.edu>
PR 435/networking * rtems/rtems_showifstat.c: rtems_showifstat misses printing the netmask
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2003-08-06 Till Strauman <strauman@slac.stanford.edu>
|
||||||
|
|
||||||
|
PR 435/networking
|
||||||
|
* rtems/rtems_showifstat.c: rtems_showifstat misses printing
|
||||||
|
the netmask
|
||||||
|
|
||||||
2003-05-29 Joel Sherrill <joel@OARcorp.com>
|
2003-05-29 Joel Sherrill <joel@OARcorp.com>
|
||||||
|
|
||||||
* rtems/rtems_syscall.c: Removed warnings.
|
* rtems/rtems_syscall.c: Removed warnings.
|
||||||
|
|||||||
@@ -11,7 +11,10 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <net/if_types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display an address
|
* Display an address
|
||||||
@@ -20,12 +23,13 @@ static int
|
|||||||
showaddress (char *name, struct sockaddr *a)
|
showaddress (char *name, struct sockaddr *a)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *sa;
|
struct sockaddr_in *sa;
|
||||||
|
char buf[17];
|
||||||
|
|
||||||
if (!a || (a->sa_family != AF_INET))
|
if (!a)
|
||||||
return 0;
|
return 0;
|
||||||
printf ("%s:", name);
|
printf ("%s:", name);
|
||||||
sa = (struct sockaddr_in *)a;
|
sa = (struct sockaddr_in *)a;
|
||||||
printf ("%-16s", inet_ntoa (sa->sin_addr));
|
printf ("%-16s", inet_ntop (AF_INET, &sa->sin_addr, buf, sizeof(buf)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,20 +42,56 @@ rtems_bsdnet_show_if_stats (void)
|
|||||||
struct ifnet *ifp;
|
struct ifnet *ifp;
|
||||||
struct ifaddr *ifa;
|
struct ifaddr *ifa;
|
||||||
unsigned short bit, flags;
|
unsigned short bit, flags;
|
||||||
int printed;
|
|
||||||
|
|
||||||
printf ("************ INTERFACE STATISTICS ************\n");
|
printf ("************ INTERFACE STATISTICS ************\n");
|
||||||
for (ifp = ifnet; ifp; ifp = ifp->if_next) {
|
for (ifp = ifnet; ifp; ifp = ifp->if_next) {
|
||||||
printf ("***** %s%d *****\n", ifp->if_name, ifp->if_unit);
|
printf ("***** %s%d *****\n", ifp->if_name, ifp->if_unit);
|
||||||
for (ifa = ifp->if_addrlist ; ifa ; ifa = ifa->ifa_next) {
|
for (ifa = ifp->if_addrlist ; ifa ; ifa = ifa->ifa_next) {
|
||||||
printed = showaddress ("Address", ifa->ifa_addr);
|
|
||||||
if (ifp->if_flags & IFF_BROADCAST)
|
if ( !ifa->ifa_addr )
|
||||||
printed |= showaddress ("Broadcast Address", ifa->ifa_broadaddr);
|
continue;
|
||||||
if (ifp->if_flags & IFF_POINTOPOINT)
|
|
||||||
printed |= showaddress ("Destination Address", ifa->ifa_dstaddr);
|
switch ( ifa->ifa_addr->sa_family ) {
|
||||||
printed |= showaddress ("Net mask", ifa->ifa_netmask);
|
case AF_LINK:
|
||||||
if (printed)
|
{
|
||||||
printf ("\n");
|
struct sockaddr_dl *sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||||
|
char *cp = LLADDR(sdl);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
switch ( sdl->sdl_type ) {
|
||||||
|
case IFT_ETHER:
|
||||||
|
if ( (i=sdl->sdl_alen) > 0 ) {
|
||||||
|
printf("Ethernet Address: ");
|
||||||
|
do {
|
||||||
|
i--;
|
||||||
|
printf("%02X%c", *cp++, i ? ':' : '\n');
|
||||||
|
} while ( i>0 );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AF_INET:
|
||||||
|
{
|
||||||
|
int printed;
|
||||||
|
printed = showaddress ("Address", ifa->ifa_addr);
|
||||||
|
if (ifp->if_flags & IFF_BROADCAST)
|
||||||
|
printed |= showaddress ("Broadcast Address", ifa->ifa_broadaddr);
|
||||||
|
if (ifp->if_flags & IFF_POINTOPOINT)
|
||||||
|
printed |= showaddress ("Destination Address", ifa->ifa_dstaddr);
|
||||||
|
printed |= showaddress ("Net mask", ifa->ifa_netmask);
|
||||||
|
if (printed)
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Flags:");
|
printf ("Flags:");
|
||||||
|
|||||||
Reference in New Issue
Block a user