diff options
author | joeyh <joeyh> | 2006-03-18 19:17:43 +0000 |
---|---|---|
committer | joeyh <joeyh> | 2006-03-18 19:17:43 +0000 |
commit | 824b3e16d5f3962f7bdba0ff3159363afad3cc68 (patch) | |
tree | e81bfad11ca345ef69c99f11f8d3abbfcca9ae53 | |
parent | fa7787ccb87cc8c47f118c65d5bbada602323a68 (diff) | |
download | moreutils-824b3e16d5f3962f7bdba0ff3159363afad3cc68.tar.gz |
* ifdata: Patch from KELEMEN Peter to add support for printing hardware0.7
interface. Closes: #357646
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | ifdata.c | 21 | ||||
-rw-r--r-- | ifdata.docbook | 8 |
3 files changed, 33 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog index 2831c75..0848452 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ -moreutils (0.7) UNRELEASED; urgency=low +moreutils (0.7) unstable; urgency=low * Add pee (pipe tee) contributed by Miek Gieben. + * ifdata: Patch from KELEMEN Peter to add support for printing hardware + interface. Closes: #357646 - -- Joey Hess <joeyh@debian.org> Tue, 14 Mar 2006 18:07:46 -0500 + -- Joey Hess <joeyh@debian.org> Sat, 18 Mar 2006 14:17:08 -0500 moreutils (0.6) unstable; urgency=low @@ -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 @@ void if_flags(char *iface) { 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 @@ void usage(char *name) { 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 @@ void please_do(int ndo, int *todo, char *ifname) { 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 @@ int main(int argc, char *argv[]) { 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")) { diff --git a/ifdata.docbook b/ifdata.docbook index 8c79b80..6adcc81 100644 --- a/ifdata.docbook +++ b/ifdata.docbook @@ -105,6 +105,14 @@ with this program; if not, write to the Free Software Foundation, Inc., </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 |