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_7-29-g49620c4


From: Sergey Poznyakoff
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_7-29-g49620c4
Date: Thu, 28 Jan 2010 08:07:15 +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  49620c40386712a2b4dd6625ff0400be4855c1ee (commit)
      from  fd031fa16e1c0366b4baab61416b2790572396e5 (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=49620c40386712a2b4dd6625ff0400be4855c1ee


commit 49620c40386712a2b4dd6625ff0400be4855c1ee
Author: Sergey Poznyakoff <address@hidden>
Date:   Thu Jan 28 10:03:53 2010 +0200

    Implement -a option; correctly print interface metric.
    
    * ifconfig/options.c (formats) <gnu-one-entry>
    <net-tools,unix,osf>: Use ${ifdisplay?}
    to select interfaces to be displayed.
    (ifs_cmdline): New global.
    (parse_opt_new_ifs): Set ifs_cmdline.
    * ifconfig/options.h (all_option, ifs_cmdline): New externs.
    * ifconfig/printif.c (format_handles) <ifdisplay?>: New handler.
    (fh_ifdisplay_query): New function.
    (fh_metric_query): Metric of 0 is OK.
    (fh_metric): Display 1 for zero metric, as other ifconfigs do.
    * ifconfig/printif.h (fh_ifdisplay_query): New prototype.

diff --git a/ChangeLog b/ChangeLog
index c9d9476..2a3ef02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2010-01-28  Sergey Poznyakoff  <address@hidden>
+
+       Implement -a option; correctly print interface metric.
+
+       * ifconfig/options.c (formats) <gnu-one-entry>
+       <net-tools,unix,osf>: Use ${ifdisplay?} to select interfaces to
+       be displayed.
+       (ifs_cmdline): New global.
+       (parse_opt_new_ifs): Set ifs_cmdline.
+       * ifconfig/options.h (all_option, ifs_cmdline): New externs.
+       * ifconfig/printif.c (format_handles) <ifdisplay?>: New handler.
+       (fh_ifdisplay_query): New function.
+       (fh_metric_query): Metric of 0 is OK.
+       (fh_metric): Display 1 for zero metric, as other ifconfigs do.
+       * ifconfig/printif.h (fh_ifdisplay_query): New prototype.
+
 2010-01-27  Sergey Poznyakoff  <address@hidden>
 
        Implement setting interface options: up, down, multicast,
@@ -12,7 +28,7 @@
        (IFF_NOCHECKSUM) [IFF_NOCHECKSUM]: New flag for "CHECKSUM".
        (cmpname, if_nameztoflag, if_format_flags): New function.
        (if_flagtoname) Avoid extra comparison.
-        (if_nametoflag): Rewrite.
+       (if_nametoflag): Rewrite.
        * ifconfig/flags.h (if_nametoflag): Updated prototype.
        (if_nameztoflag, if_format_flags): New prototypes.
        * ifconfig/options.c (all_option): New global variable.
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 6064fe7..106e79a 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -67,6 +67,7 @@ struct format formats[] = {
   {"gnu", "${first?}{}{${\\n}}${format}{gnu-one-entry}"},
   {"gnu-one-entry",
    "${format}{check-existence}"
+   "${ifdisplay?}{"
    "${name} (${index}):${\\n}"
    "${addr?}{  inet address ${tab}{16}${addr}${\\n}}"
    "${netmask?}{  netmask ${tab}{16}${netmask}${\\n}}"
@@ -77,10 +78,13 @@ struct format formats[] = {
    "${metric?}{  metric ${tab}{16}${metric}${\\n}}"
    "${exists?}{hwtype?}{${hwtype?}{  link encap ${tab}{16}${hwtype}${\\n}}}"
    "${exists?}{hwaddr?}{${hwaddr?}{  hardware addr ${tab}{16}${hwaddr}${\\n}}}"
-   "${exists?}{txqlen?}{${txqlen?}{  tx queue len 
${tab}{16}${txqlen}${\\n}}}"},
+   "${exists?}{txqlen?}{${txqlen?}{  tx queue len ${tab}{16}${txqlen}${\\n}}}"
+   "}"
+  },
   /* Resembles the output of ifconfig 1.39 (1999-03-19) in net-tools 1.52.  */
   {"net-tools",
    "${format}{check-existence}"
+   "${ifdisplay?}{"
    "${name}${exists?}{hwtype?}{${hwtype?}{${tab}{10}Link encap:${hwtype}}"
    "${hwaddr?}{  HWaddr ${hwaddr}}}${\\n}"
    "${addr?}{${tab}{10}inet addr:${addr}"
@@ -115,11 +119,13 @@ struct format formats[] = {
    "${newline}"
    "}}}"
    "${newline}"
+   "}"
   },
   /* Resembles the output of ifconfig shipped with unix systems like
      Solaris 2.7 or HPUX 10.20.  */
   {"unix",
    "${format}{check-existence}"
+   "${ifdisplay?}{"
    "${name}: flags=${flags}{number}<${flags}{string}{,}>"
    "${mtu?}{ mtu ${mtu}}${\\n}"
    "${addr?}{${\\t}inet ${addr}"
@@ -127,15 +133,20 @@ struct format formats[] = {
    "${netmask}{2}{%02x}${netmask}{3}{%02x}"
    "${brdaddr?}{ broadcast ${brdaddr}}${\\n}}"
    "${exists?}{hwtype?}{${hwtype?}{${\\t}${hwtype}"
-   "}${exists?}{hwaddr?}{${hwaddr?}{ ${hwaddr}}}${\\n}}"},
+   "}${exists?}{hwaddr?}{${hwaddr?}{ ${hwaddr}}}${\\n}}"
+   "}"
+  },
   /* Resembles the output of ifconfig shipped with OSF 4.0g.  */
   {"osf",
    "${format}{check-existence}"
+   "${ifdisplay?}{"
    "${name}: flags=${flags}{number}{%x}<${flags}{string}{,}>${\\n}"
    "${addr?}{${\\t}inet ${addr}"
    " netmask ${netmask}{0}{%02x}${netmask}{1}{%02x}"
    "${netmask}{2}{%02x}${netmask}{3}{%02x}"
-   "${brdaddr?}{ broadcast ${brdaddr}}" "${mtu?}{ ipmtu ${mtu}}${\\n}}"},
+   "${brdaddr?}{ broadcast ${brdaddr}}" "${mtu?}{ ipmtu ${mtu}}${\\n}}"
+   "}"
+  },
   /* If interface does not exist, print error message and exit. */
   {"check-existence",
    "${index?}{}"
@@ -148,6 +159,8 @@ struct format formats[] = {
 const char *default_format;
 /* Display all interfaces, even if down */
 int all_option;
+/* True if interfaces were given in the command line */
+int ifs_cmdline;
 
 enum {
   METRIC_OPTION = 256,
@@ -200,9 +213,11 @@ parse_opt_new_ifs (char *name)
 {
   struct ifconfig *ifp;
 
+  ifs_cmdline = 1;
   ifs = realloc (ifs, ++nifs * sizeof (struct ifconfig));
   if (!ifs)
-    error (EXIT_FAILURE, errno, "can't get memory for interface 
configuration");
+    error (EXIT_FAILURE, errno,
+          "can't get memory for interface configuration");
   ifp = &ifs[nifs - 1];
   *ifp = ifconfig_initializer;
   ifp->name = name;
diff --git a/ifconfig/options.h b/ifconfig/options.h
index 43b5d33..5e2a6ab 100644
--- a/ifconfig/options.h
+++ b/ifconfig/options.h
@@ -61,6 +61,8 @@ struct format
 };
 
 extern struct format formats[];
+extern int all_option;
+extern int ifs_cmdline;
 
 /* Array of interfaces mentioned on the command line.  */
 extern struct ifconfig *ifs;
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index 4db2792..67a4b28 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -69,6 +69,7 @@ struct format_handle format_handles[] = {
   {"\\n", fh_newline},
   {"\\t", fh_tabulator},
   {"first?", fh_first},
+  {"ifdisplay?", fh_ifdisplay_query},
   {"tab", fh_tab},
   {"join", fh_join},
   {"exists?", fh_exists_query},
@@ -382,6 +383,25 @@ fh_first (format_data_t form, int argc, char *argv[])
   select_arg (form, argc, argv, form->first ? 0 : 1);
 }
 
+void
+fh_ifdisplay_query (format_data_t form, int argc, char *argv[])
+{
+  int n;
+
+#ifdef SIOCGIFFLAGS
+  int f;
+  int rev;
+
+  n = !(all_option || ifs_cmdline
+       || ((f = if_nameztoflag ("UP", &rev))
+           && ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) == 0
+           && (f & form->ifr->ifr_flags)));
+#else
+  n = 0;
+#endif
+  select_arg (form, argc, argv, n);
+}
+
 /* A tab implementation, which fills with spaces up to requested column or next
    tabstop.  */
 void
@@ -689,7 +709,7 @@ fh_metric_query (format_data_t form, int argc, char *argv[])
 {
 #ifdef SIOCGIFMETRIC
   if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) >= 0)
-    select_arg (form, argc, argv, (form->ifr->ifr_metric > 0) ? 0 : 1);
+    select_arg (form, argc, argv, 0);
   else
 #endif
     select_arg (form, argc, argv, 1);
@@ -704,7 +724,8 @@ fh_metric (format_data_t form, int argc, char *argv[])
           "SIOCGIFMETRIC failed for interface `%s'",
           form->ifr->ifr_name);
   else
-    put_int (form, argc, argv, form->ifr->ifr_metric);
+    put_int (form, argc, argv,
+            form->ifr->ifr_metric ? form->ifr->ifr_metric : 1);
 #else
   *column += printf ("(not available)");
   had_output = 1;
diff --git a/ifconfig/printif.h b/ifconfig/printif.h
index 9038572..b4391ce 100644
--- a/ifconfig/printif.h
+++ b/ifconfig/printif.h
@@ -77,6 +77,7 @@ void fh_nothing (format_data_t form, int argc, char *argv[]);
 void fh_newline (format_data_t form, int argc, char *argv[]);
 void fh_tabulator (format_data_t form, int argc, char *argv[]);
 void fh_first (format_data_t form, int argc, char *argv[]);
+void fh_ifdisplay_query (format_data_t form, int argc, char *argv[]);
 void fh_tab (format_data_t form, int argc, char *argv[]);
 void fh_join (format_data_t form, int argc, char *argv[]);
 void fh_exists_query (format_data_t form, int argc, char *argv[]);

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

Summary of changes:
 ChangeLog          |   18 +++++++++++++++++-
 ifconfig/options.c |   23 +++++++++++++++++++----
 ifconfig/options.h |    2 ++
 ifconfig/printif.c |   25 +++++++++++++++++++++++--
 ifconfig/printif.h |    1 +
 5 files changed, 62 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 




reply via email to

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