]> err.no Git - moreutils/commitdiff
* ifdata: Patch from KELEMEN Peter to add support for printing hardware 0.7
authorjoeyh <joeyh>
Sat, 18 Mar 2006 19:17:43 +0000 (19:17 +0000)
committerjoeyh <joeyh>
Sat, 18 Mar 2006 19:17:43 +0000 (19:17 +0000)
  interface. Closes: #357646

debian/changelog
ifdata.c
ifdata.docbook

index 2831c7559a401ed23187e421991c7b4295b150f0..0848452fb3c0624d66eed25c6c3f813d61b48b9e 100644 (file)
@@ -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
 
index c65ef16affe359816e8acb77e0b2b66e0db46eff..1f1eb2afaa5e5ba1b057731e9df1b4237313c0e8 100644 (file)
--- a/ifdata.c
+++ b/ifdata.c
@@ -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")) {
index 8c79b8018edc5618bcc1f867365149b781ebbe9a..6adcc818487a34c9a7b947477a997f182ef7629b 100644 (file)
@@ -104,6 +104,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
                        </listitem>
                </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>