Package: moreutils
Version: 0.6
Severity: wishlist
Tags: patch
It would be nice if ifdata(1) could print the hardware address of the
interface.
Peter
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.15-vm2g-inara.1
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages moreutils depends on:
ii libc6 2.3.6-3 GNU C Library: Shared libraries an
ii perl 5.8.8-3 Larry Wall's Practical Extraction
moreutils recommends no packages.
-- no debconf information
--- ifdata.c.orig 2006-03-18 19:12:00.000000000 +0100
+++ ifdata.c 2006-03-18 19:43:21.000000000 +0100
@@ -41,6 +41,7 @@
#define DO_SOUTCARRIER 25
#define DO_SOUTMULTICAST 26
#define DO_PNETWORK 27
+#define DO_PHWADDRESS 28
struct if_stat {
unsigned long long int in_packets;
@@ -138,6 +139,20 @@
PRINT_IF(0xffff0000,"Unknown-flags");
}
+void if_hwaddr(char *iface) {
+ unsigned char *hwaddr;
+
+ PREPARE_SOCK(iface);
+ CALL_IOCTL(SIOCGIFHWADDR);
+ if (res < 0) {
+ CALL_ERROR();
+ }
+ hwaddr = (unsigned char *)req.ifr_hwaddr.sa_data;
+ printf("%02X:%02X:%02X:%02X:%02X:%02X",
+ hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
+ END_SOCK;
+}
+
struct sockaddr *if_addr(char *iface) {
PREPARE_SOCK(iface);
CALL_IOCTL(SIOCGIFADDR);
@@ -324,6 +339,7 @@
fprintf(stderr," -e Says if iface exists or not\n"
" -p Print out the whole config of iface\n"
" -pe Print out yes or no according to existence\n"
+ " -ph Print out the hardware address\n"
" -pa Print out the address\n"
" -pn Print netmask\n"
" -pN Print network address\n"
@@ -379,6 +395,9 @@
printf("no");
}
break;
+ case DO_PHWADDRESS:
+ if_hwaddr(ifname);
+ break;
case DO_PADDRESS:
sadr=if_addr(ifname);
PRINT_OR_ERR(sadr);
@@ -531,6 +550,8 @@
add_do(&ndo,&todo,DO_EXISTS);
} else if (!strcmp(argv[narg],"-p")) {
add_do(&ndo,&todo,DO_PALL);
+ } else if (!strcmp(argv[narg],"-ph")) {
+ add_do(&ndo,&todo,DO_PHWADDRESS);
} else if (!strcmp(argv[narg],"-pa")) {
add_do(&ndo,&todo,DO_PADDRESS);
} else if (!strcmp(argv[narg],"-pn")) {
--- ifdata.docbook.orig 2006-03-18 19:32:24.000000000 +0100
+++ ifdata.docbook 2006-03-18 19:33:00.000000000 +0100
@@ -105,6 +105,14 @@
</varlistentry>
<varlistentry>
+ <term><option>-ph</option></term>
+ <listitem>
+ <para>Prints the hardware address of the
+ interface.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-pa</option></term>
<listitem>
<para>Prints the IPv4 address of the