commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_8-11-ge071c3e


From: Giuseppe Scrivano
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_8-11-ge071c3e
Date: Tue, 17 Aug 2010 23:33:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  e071c3e5b215ad725d23932ef0d2cacaa1701f17 (commit)
      from  72e891b83a41264f2f54183edbf7f264eab488aa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=e071c3e5b215ad725d23932ef0d2cacaa1701f17


commit e071c3e5b215ad725d23932ef0d2cacaa1701f17
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Aug 18 01:28:09 2010 +0200

    Under GNU/Linux print interfaces without an address with ifconfig -a.
    
    * bootstrap.conf (gnulib_modules): Add module `read-file'.
    
    * NEWS: Update.
    
    * ifconfig/options.c (parse_cmdline): Use system_if_nameindex, not
    if_nameindex.
    
    * ifconfig/system.h: Include <if_index.h>.
    
    * ifconfig/system/generic.c (system_if_nameindex): New variable.
    * ifconfig/system/hpux.c (system_if_nameindex): New variable.
    * ifconfig/system/osf.c (system_if_nameindex): Likewise.
    * ifconfig/system/qnc.c (system_if_nameindex): Likewise.
    * ifconfig/system/solaris.c (system_if_nameindex): Likewise.
    
    * ifconfig/system/linux.c (linux_if_nameindex): New function.
    (system_if_nameindex): New variable.

diff --git a/ChangeLog b/ChangeLog
index 36dbb5f..d52508b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2010-08-18  Giuseppe Scrivano  <address@hidden>
+
+       Under GNU/Linux print interfaces without an address with ifconfig -a.
+       * bootstrap.conf (gnulib_modules): Add module `read-file'.
+
+       * NEWS: Update.
+
+       * ifconfig/options.c (parse_cmdline): Use system_if_nameindex, not
+       if_nameindex.
+
+       * ifconfig/system.h: Include <if_index.h>.
+
+       * ifconfig/system/generic.c (system_if_nameindex): New variable.
+       * ifconfig/system/hpux.c (system_if_nameindex): New variable.
+       * ifconfig/system/osf.c (system_if_nameindex): Likewise.
+       * ifconfig/system/qnc.c (system_if_nameindex): Likewise.
+       * ifconfig/system/solaris.c (system_if_nameindex): Likewise.
+
+       * ifconfig/system/linux.c (linux_if_nameindex): New function.
+       (system_if_nameindex): New variable.
+
 2010-08-16  Sergey Poznyakoff  <address@hidden>
 
        * ifconfig/flags.c (flag_char_tab): Protect the
diff --git a/NEWS b/NEWS
index 4583586..2f2dfdf 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,14 @@ See the end of this file for for license conditions.
 
 Please send inetutils bug reports to <address@hidden>.
 
+XXX YY, ZZ
+Version A.B:
+
+* ifconfig
+
+Now under GNU/Linux "ifconfig -a" shows also interfaces without an address.
+
+
 May 15, 2010
 Version 1.8:
 
diff --git a/bootstrap.conf b/bootstrap.conf
index bbb5c2e..facab0a 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -53,6 +53,7 @@ minmax
 obstack
 poll
 progname
+read-file
 readline
 readutmp
 realloc
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 0bcef2c..c990bf7 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -590,7 +590,7 @@ parse_cmdline (int argc, char *argv[])
       /* No interfaces specified.  Get a list of all interfaces.  */
       struct if_nameindex *ifnx, *ifnxp;
 
-      ifnx = ifnxp = if_nameindex ();
+      ifnx = ifnxp = system_if_nameindex ();
       if (!ifnx)
        error (EXIT_FAILURE, 0, "could not get list of interfaces");
       while (ifnxp->if_index != 0 || ifnxp->if_name != NULL)
diff --git a/ifconfig/system.h b/ifconfig/system.h
index 0a74da8..31a703e 100644
--- a/ifconfig/system.h
+++ b/ifconfig/system.h
@@ -23,6 +23,8 @@
 # define IFCONFIG_SYSTEM_H
 
 
+# include <if_index.h>
+
 /* Option parsing.  */
 
 extern struct argp_child system_argp_child;
@@ -85,6 +87,7 @@ int system_configure (int sfd, struct ifreq *ifr,
 # endif
 
 
+extern struct if_nameindex* (*system_if_nameindex) (void);
 
 # if defined(__linux__)
 #  include "system/linux.h"
diff --git a/ifconfig/system/hpux.c b/ifconfig/system/hpux.c
index 5ba5a0b..50941bb 100644
--- a/ifconfig/system/hpux.c
+++ b/ifconfig/system/hpux.c
@@ -162,3 +162,9 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
 {
   return 0;
 }
+
+
+
+/* System hooks. */
+
+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;
diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index fd5a1b2..026cb4d 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -46,6 +46,8 @@
 #include <net/if_arp.h>
 #include <linux/if_ether.h>
 
+#include <read-file.h>
+
 #include "../ifconfig.h"
 
 
@@ -846,3 +848,86 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
     }
   return 0;
 }
+
+static struct if_nameindex *
+linux_if_nameindex (void)
+{
+  char *content, *it;
+  size_t length, index;
+  struct if_nameindex *idx = NULL;
+  int fd;
+
+  fd = socket (AF_INET, SOCK_DGRAM, 0);
+  if (fd < 0)
+    return NULL;
+
+  content = read_file (PATH_PROCNET_DEV, &length);
+  if (content == NULL)
+    return NULL;
+
+  /* Count how many interfaces we have.  */
+  {
+    size_t n = 0;
+    it = content;
+    do
+      {
+        it = memchr (it + 1, ':', length - (it - content));
+        n++;
+      }
+    while (it);
+
+    idx = malloc (n * sizeof (*idx));
+    if (idx == NULL)
+      {
+        int saved_errno = errno;
+        close (fd);
+        free (content);
+        errno = saved_errno;
+        return NULL;
+      }
+  }
+
+  for (it = memchr (content, ':', length), index = 0; it;
+       it = memchr (it, ':', it - content), index++)
+    {
+      char *start = it - 1;
+      *it = '\0';
+
+      while (*start != ' ' && *start != '\n')
+        start--;
+
+      idx[index].if_name = strdup (start + 1);
+      idx[index].if_index = index + 1;
+
+# if defined(SIOCGIFINDEX)
+      {
+        struct ifreq cur;
+        strcpy (cur.ifr_name, idx[index].if_name);
+        cur.ifr_index = -1;
+        if (ioctl (fd, SIOCGIFINDEX, &cur) >= 0)
+          idx[index].if_index = cur.ifr_index;
+      }
+# endif
+
+      if (idx[index].if_name == NULL)
+        {
+          int saved_errno = errno;
+          close (fd);
+          free (content);
+          errno = saved_errno;
+          return NULL;
+        }
+    }
+
+  idx[index].if_index = 0;
+  idx[index].if_name = NULL;
+
+  free (content);
+  return idx;
+}
+
+
+
+/* System hooks. */
+
+struct if_nameindex* (*system_if_nameindex) (void) = linux_if_nameindex;
diff --git a/ifconfig/system/osf.c b/ifconfig/system/osf.c
index 4d361d0..65830dd 100644
--- a/ifconfig/system/osf.c
+++ b/ifconfig/system/osf.c
@@ -156,3 +156,9 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
 {
   return 0;
 }
+
+
+
+/* System hooks. */
+
+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;
diff --git a/ifconfig/system/qnx.c b/ifconfig/system/qnx.c
index a2a3abd..260234d 100644
--- a/ifconfig/system/qnx.c
+++ b/ifconfig/system/qnx.c
@@ -65,3 +65,9 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
 {
   return 0;
 }
+
+
+
+/* System hooks. */
+
+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;
diff --git a/ifconfig/system/solaris.c b/ifconfig/system/solaris.c
index 2f5884f..27c2763 100644
--- a/ifconfig/system/solaris.c
+++ b/ifconfig/system/solaris.c
@@ -178,3 +178,9 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
   return 0;
 #endif
 }
+
+
+
+/* System hooks. */
+
+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |   21 +++++++++++
 NEWS                      |    8 ++++
 bootstrap.conf            |    1 +
 ifconfig/options.c        |    2 +-
 ifconfig/system.h         |    3 ++
 ifconfig/system/hpux.c    |    6 +++
 ifconfig/system/linux.c   |   85 +++++++++++++++++++++++++++++++++++++++++++++
 ifconfig/system/osf.c     |    6 +++
 ifconfig/system/qnx.c     |    6 +++
 ifconfig/system/solaris.c |    6 +++
 10 files changed, 143 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]