summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2003-08-06 14:39:16 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2003-08-06 14:39:16 +0000
commit1d2dbec76d97b79163e7cbb21588ae4b7fa1a5ec (patch)
treedb915f28a61d4e14e8c8ee4a33faf5ef72523293
parentd931f10795602c4b6419d61e1d91ffb6e0473922 (diff)
downloadrtems-1d2dbec76d97b79163e7cbb21588ae4b7fa1a5ec.tar.bz2
2003-08-06 Till Strauman <strauman@slac.stanford.edu>
PR 435/networking * rtems/rtems_showifstat.c: rtems_showifstat misses printing the netmask
-rw-r--r--cpukit/libnetworking/ChangeLog6
-rw-r--r--cpukit/libnetworking/rtems/rtems_showifstat.c62
2 files changed, 57 insertions, 11 deletions
diff --git a/cpukit/libnetworking/ChangeLog b/cpukit/libnetworking/ChangeLog
index 649351d086..47410683ab 100644
--- a/cpukit/libnetworking/ChangeLog
+++ b/cpukit/libnetworking/ChangeLog
@@ -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-07-08 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* configure.ac: Remove (Merged into ../configure.ac).
diff --git a/cpukit/libnetworking/rtems/rtems_showifstat.c b/cpukit/libnetworking/rtems/rtems_showifstat.c
index 20055517f6..daf456e933 100644
--- a/cpukit/libnetworking/rtems/rtems_showifstat.c
+++ b/cpukit/libnetworking/rtems/rtems_showifstat.c
@@ -11,7 +11,10 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
/*
* Display an address
@@ -20,12 +23,13 @@ static int
showaddress (char *name, struct sockaddr *a)
{
struct sockaddr_in *sa;
+ char buf[17];
- if (!a || (a->sa_family != AF_INET))
+ if (!a)
return 0;
printf ("%s:", name);
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;
}
@@ -38,20 +42,56 @@ rtems_bsdnet_show_if_stats (void)
struct ifnet *ifp;
struct ifaddr *ifa;
unsigned short bit, flags;
- int printed;
printf ("************ INTERFACE STATISTICS ************\n");
for (ifp = ifnet; ifp; ifp = ifp->if_next) {
printf ("***** %s%d *****\n", ifp->if_name, ifp->if_unit);
for (ifa = ifp->if_addrlist ; ifa ; ifa = ifa->ifa_next) {
- 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");
+
+ if ( !ifa->ifa_addr )
+ continue;
+
+ switch ( ifa->ifa_addr->sa_family ) {
+ case AF_LINK:
+ {
+ 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:");