summaryrefslogtreecommitdiffstats
path: root/netcfg/netcfg.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-01-24 17:09:32 -0800
committerDmitry Shmidt <dimitrysh@google.com>2011-01-24 17:09:32 -0800
commit97186a9c3d1874ac79f94676dc9f0df1f0815e1f (patch)
treea77847990193c71987ef8005bb98169c30283ede /netcfg/netcfg.c
parent08cdb756be0c8848424e8a113e694f35711e43a0 (diff)
downloadsystem_core-97186a9c3d1874ac79f94676dc9f0df1f0815e1f.zip
system_core-97186a9c3d1874ac79f94676dc9f0df1f0815e1f.tar.gz
system_core-97186a9c3d1874ac79f94676dc9f0df1f0815e1f.tar.bz2
netcfg: Add MAC address to interface dump
Change-Id: I52b3336a66224c9ae19a4c80cc706890742d4130 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'netcfg/netcfg.c')
-rw-r--r--netcfg/netcfg.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/netcfg/netcfg.c b/netcfg/netcfg.c
index 9cd883a..aae1228 100644
--- a/netcfg/netcfg.c
+++ b/netcfg/netcfg.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <dirent.h>
#include <netinet/ether.h>
+#include <netinet/if_ether.h>
#include <netutils/ifc.h>
#include <netutils/dhcp.h>
@@ -44,13 +45,14 @@ const char *ipaddr(in_addr_t addr)
void usage(void)
{
fprintf(stderr,"usage: netcfg [<interface> {dhcp|up|down}]\n");
- exit(1);
+ exit(1);
}
int dump_interface(const char *name)
{
unsigned addr, mask, flags;
-
+ unsigned char hwbuf[ETH_ALEN];
+
if(ifc_get_info(name, &addr, &mask, &flags)) {
return 0;
}
@@ -58,7 +60,15 @@ int dump_interface(const char *name)
printf("%-8s %s ", name, flags & 1 ? "UP " : "DOWN");
printf("%-16s", ipaddr(addr));
printf("%-16s", ipaddr(mask));
- printf("0x%08x\n", flags);
+ printf("0x%08x ", flags);
+ if (!ifc_get_hwaddr(name, hwbuf)) {
+ int i;
+ for(i=0; i < (ETH_ALEN-1); i++)
+ printf("%02x:", hwbuf[i]);
+ printf("%02x\n", hwbuf[i]);
+ } else {
+ printf("\n");
+ }
return 0;
}
@@ -66,10 +76,10 @@ int dump_interfaces(void)
{
DIR *d;
struct dirent *de;
-
+
d = opendir("/sys/class/net");
if(d == 0) return -1;
-
+
while((de = readdir(d))) {
if(de->d_name[0] == '.') continue;
dump_interface(de->d_name);