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_9_1-221-g18843


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-221-g188433b
Date: Thu, 06 Dec 2012 21:26:11 +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  188433bc0760e8ea8f2947831d1a53b78bc523e5 (commit)
       via  72e61402af942ed672b3dd6e937aa4854db330ae (commit)
       via  0d19e38f4f71e2137d88b4aafa917f519fc70e9d (commit)
       via  065f43884cfbc7ba1dc7639d4bd87a650fa05b33 (commit)
      from  150fca45402469de012f4bd9f64bd8ca5b2e89f2 (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=188433bc0760e8ea8f2947831d1a53b78bc523e5


commit 188433bc0760e8ea8f2947831d1a53b78bc523e5
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Dec 6 14:32:41 2012 +0100

    ifconfig: Protect interface flag operations.
    
    Cover many compiler warnings in ifconfig.

diff --git a/ChangeLog b/ChangeLog
index 8665f35..483ecc6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,69 @@
+2012-12-06  Mats Erik Andersson  <address@hidden>
+
+       ifconfig: Allow `--up', `--down' to be used before
+       interface selection.  Applies to all flags.
+
+       * ifconfig/options.c (pending_setflags, pending_clrflags):
+       New variables.
+       (parse_opt_set_flag): Use parameters to manipulate only
+       pending_setflags and pending_clrflags, not `ifp->*flags',
+       since the latter need not be allocated.
+       (parse_opt_finalize): Assign values to `ifp->setflags'
+       and `ifp->clrflags' using `pending_*flags'.
+       * ifconfig/options.h (pending_setflags, pending_clrflags):
+       New external declarations.
+
+       Detect member `struct ifreq.ifr_mtu'.
+
+       * configure.ac (HAVE_STRUCT_IFREQ_IFR_MTU): Check for
+       member ifr_mtu in `struct ifreq'.
+       * ifconfig/system/solaris.h (ifr_mtu)
+       [!HAVE_STRUCT_IFREQ_IFR_MTU]: Protect macro definition.
+
+       ifconfig: Attend to many compiler warnings.
+
+       * ifconfig/flags.c (if_flags): Set member `rev' to 0,
+       whenever it was missing.  Remove duplicate elements
+       "OACTIVE" and "D2".  End array with full element.
+       (flag_char_tab): End array with full stop element.
+       * ifconfig/options.c: Include <unused-parameter.h>.
+       (ifconfig_initializer): Initialize all members.
+       (formats): End array with full stop element.
+       (argp_options): New local macro GRP.  Add GRP to every
+       element.  Add description to `peer' and `brdaddr'.
+       End array with full stop element.
+       (parse_opt_set_flag): Mark ifp as unused.
+       (default_help_filter): Mark input as unused.
+       (argp): Add NULL as missing, last element.
+       * ifconfig/printif.c: Include <unused-parameter.h>.
+       (put_char, put_int, put_ulong): Mark form as unused.
+       (put_flags_short): Mark argc and argv as unused.
+       (fh_nothing): Mark all parameters as unused.
+       (fh_newline, fh_tabulator, fh_progname, fh_name)
+       (fh_index): Mark argc and argv as unused.
+       (fh_exit): Mark form as unused.
+
+       * ifconfig/system/bsd.c: Include <unused-parameter.h>.
+       (system_parse_opt, system_configure): Mark all parameters
+       as unused.
+       (system_fh_hwaddr, system_fh_hwtype): Mark argc and argv
+       as unused.
+
+       * ifconfig/system/linux.c: Include <unused-parameter.h>.
+       (print_hwaddr_ether, print_hwaddr_arcnet, print_hwaddr_dlci)
+       (print_hwaddr_irda, print_hwaddr_rose): Mark form as unused.
+       Set had_output.
+       (print_hwaddr_ax25): Set had_output.
+       (system_fh_hwaddr, system_hw_type): Mark argc and argv as unused.
+       (linux_argp_options): Add group member to element "txqlen".
+       End array with full stop element.
+       (linux_argp): Fill missing members with NULL.
+
+       * ifconfig/system/solaris.c: Include <unused-parameter.h>.
+       (system_parse_opt): Mark all parameters as unused.
+       (system_configure) [!IF_VALID_TXQLEN]: Trivially use
+       paramaters sfd, ifr, and ifs.
+
 2012-12-04  Mats Erik Andersson  <address@hidden>
 
        * ifconfig/system/bsd.c (system_help): Update.
diff --git a/configure.ac b/configure.ac
index 9ecc492..c94e996 100644
--- a/configure.ac
+++ b/configure.ac
@@ -694,12 +694,13 @@ if test "$ac_cv_header_utmpx_h" = yes; then
 fi
 
 IU_CHECK_MEMBERS([struct ifreq.ifr_index,
-                  struct ifreq.ifr_netmask,
-                  struct ifreq.ifr_broadaddr,
+                 struct ifreq.ifr_netmask,
+                 struct ifreq.ifr_broadaddr,
+                 struct ifreq.ifr_mtu,
                  struct ifreq.ifr_map], , ,
-                 [#include <sys/types.h>
-                  #include <sys/socket.h>
-                  #include <net/if.h>])
+                [#include <sys/types.h>
+                 #include <sys/socket.h>
+                 #include <net/if.h>])
 
 IU_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
                  [#include <sys/types.h>
diff --git a/ifconfig/flags.c b/ifconfig/flags.c
index 6dcd3cc..6d5a573 100644
--- a/ifconfig/flags.c
+++ b/ifconfig/flags.c
@@ -46,179 +46,173 @@ struct if_flag
        10.20 and OSF 4.0g.  */
 
 #ifdef IFF_UP                  /* Interface is up.  */
-    {"UP", IFF_UP},
+    {"UP", IFF_UP, 0},
 #endif
 #ifdef IFF_BROADCAST           /* Broadcast address is valid.  */
-    {"BROADCAST", IFF_BROADCAST},
+    {"BROADCAST", IFF_BROADCAST, 0},
 #endif
 #ifdef IFF_DEBUG               /* Debugging is turned on.  */
-    {"DEBUG", IFF_DEBUG},
+    {"DEBUG", IFF_DEBUG, 0},
 #endif
 #ifdef IFF_LOOPBACK            /* Is a loopback net.  */
-    {"LOOPBACK", IFF_LOOPBACK},
+    {"LOOPBACK", IFF_LOOPBACK, 0},
 #endif
 #ifdef IFF_POINTOPOINT         /* Interface is a point-to-point link.  */
-    {"POINTOPOINT", IFF_POINTOPOINT},
+    {"POINTOPOINT", IFF_POINTOPOINT, 0},
 #endif
 #ifdef IFF_RUNNING             /* Resources allocated.  */
-    {"RUNNING", IFF_RUNNING},
+    {"RUNNING", IFF_RUNNING, 0},
 #endif
 #ifdef IFF_NOARP               /* No address resolution protocol.  */
-    {"NOARP", IFF_NOARP},
+    {"NOARP", IFF_NOARP, 0},
     {"ARP", IFF_NOARP, 1},
 #endif
 #ifdef IFF_PROMISC             /* Receive all packets.  */
-    {"PROMISC", IFF_PROMISC},
+    {"PROMISC", IFF_PROMISC, 0},
 #endif
 #ifdef IFF_ALLMULTI            /* Receive all multicast packets.  */
-    {"ALLMULTI", IFF_ALLMULTI},
+    {"ALLMULTI", IFF_ALLMULTI, 0},
 #endif
 #ifdef IFF_MULTICAST           /* Supports multicast.  */
-    {"MULTICAST", IFF_MULTICAST},
+    {"MULTICAST", IFF_MULTICAST, 0},
 #endif
     /* Usually available on all systems which derive the network
        interface from BSD (see above), but with exceptions noted.  */
 #ifdef IFF_NOTRAILERS          /* Avoid use of trailers.  */
     /* Obsoleted on FreeBSD systems.  */
-    {"NOTRAILERS", IFF_NOTRAILERS},
+    {"NOTRAILERS", IFF_NOTRAILERS, 0},
     {"TRAILERS", IFF_NOTRAILERS, 1},
 #endif
     /* Available on GNU and Linux systems.  */
 #ifdef IFF_MASTER              /* Master of a load balancer.  */
-    {"MASTER", IFF_MASTER},
+    {"MASTER", IFF_MASTER, 0},
 #endif
 #ifdef IFF_SLAVE               /* Slave of a load balancer.  */
-    {"SLAVE", IFF_SLAVE},
+    {"SLAVE", IFF_SLAVE, 0},
 #endif
 #ifdef IFF_PORTSEL             /* Can set media type.  */
-    {"PORTSEL", IFF_PORTSEL},
+    {"PORTSEL", IFF_PORTSEL, 0},
 #endif
 #ifdef IFF_AUTOMEDIA           /* Auto media select is active.  */
-    {"AUTOMEDIA", IFF_AUTOMEDIA},
+    {"AUTOMEDIA", IFF_AUTOMEDIA, 0},
 #endif
     /* Available on Linux 2.4 systems (not glibc <= 2.2.1).  */
 #ifdef IFF_DYNAMIC             /* Dialup service with hanging addresses.  */
-    {"DYNAMIC", IFF_DYNAMIC},
+    {"DYNAMIC", IFF_DYNAMIC, 0},
 #endif
     /* Available on FreeBSD and OSF 4.0g systems.  */
 #ifdef IFF_OACTIVE             /* Transmission is in progress.  */
-    {"OACTIVE", IFF_OACTIVE},
+    {"OACTIVE", IFF_OACTIVE, 0},
 #endif
 #ifdef IFF_SIMPLEX             /* Can't hear own transmissions.  */
-    {"SIMPLEX", IFF_SIMPLEX},
+    {"SIMPLEX", IFF_SIMPLEX, 0},
 #endif
     /* Available on FreeBSD systems.  */
 #ifdef IFF_LINK0               /* Per link layer defined bit.  */
-    {"LINK0", IFF_LINK0},
+    {"LINK0", IFF_LINK0, 0},
 #endif
 #ifdef IFF_LINK1               /* Per link layer defined bit.  */
-    {"LINK1", IFF_LINK1},
+    {"LINK1", IFF_LINK1, 0},
 #endif
 #if defined IFF_LINK2 && defined IFF_ALTPHYS
 # if IFF_LINK2 == IFF_ALTPHYS
     /* IFF_ALTPHYS == IFF_LINK2 on FreeBSD.  This entry is used as a
        fallback for if_flagtoname conversion, if no relevant EXPECT_
        macro is specified to figure out which one is meant.  */
-    {"LINK2/ALTPHYS", IFF_LINK2},
+    {"LINK2/ALTPHYS", IFF_LINK2, 0},
 # endif
 #endif
 #ifdef IFF_LINK2               /* Per link layer defined bit.  */
-    {"LINK2", IFF_LINK2},
+    {"LINK2", IFF_LINK2, 0},
 #endif
 #ifdef IFF_ALTPHYS             /* Use alternate physical connection.  */
-    {"ALTPHYS", IFF_ALTPHYS},
+    {"ALTPHYS", IFF_ALTPHYS, 0},
 #endif
     /* Available on Solaris 2.7 systems.  */
 #ifdef IFF_INTELLIGENT         /* Protocol code on board.  */
-    {"INTELLIGENT", IFF_INTELLIGENT},
+    {"INTELLIGENT", IFF_INTELLIGENT, 0},
 #endif
 #ifdef IFF_MULTI_BCAST         /* Multicast using broadcast address.  */
-    {"MULTI_BCAST", IFF_MULTI_BCAST},
+    {"MULTI_BCAST", IFF_MULTI_BCAST, 0},
 #endif
 #ifdef IFF_UNNUMBERED          /* Address is not unique.  */
-    {"UNNUMBERED", IFF_UNNUMBERED},
+    {"UNNUMBERED", IFF_UNNUMBERED, 0},
 #endif
 #ifdef IFF_DHCPRUNNING         /* Interface is under control of DHCP.  */
-    {"DHCPRUNNING", IFF_DHCPRUNNING},
+    {"DHCPRUNNING", IFF_DHCPRUNNING, 0},
 #endif
 #ifdef IFF_PRIVATE             /* Do not advertise.  */
-    {"PRIVATE", IFF_PRIVATE},
+    {"PRIVATE", IFF_PRIVATE, 0},
 #endif
     /* Available on HP-UX 10.20 systems.  */
 #ifdef IFF_NOTRAILERS          /* Avoid use of trailers.  */
-    {"NOTRAILERS", IFF_NOTRAILERS},
+    {"NOTRAILERS", IFF_NOTRAILERS, 0},
     {"TRAILERS", IFF_NOTRAILERS, 1},
 #endif
 #ifdef IFF_LOCALSUBNETS                /* Subnets of this net are local.  */
-    {"LOCALSUBNETS", IFF_LOCALSUBNETS},
+    {"LOCALSUBNETS", IFF_LOCALSUBNETS, 0},
 #endif
 #ifdef IFF_CKO                 /* Interface supports header checksum.  */
-    {"CKO", IFF_CKO},
+    {"CKO", IFF_CKO, 0},
 #endif
 #ifdef IFF_NOACC               /* No data access on outbound.  */
-    {"NOACC", IFF_NOACC},
+    {"NOACC", IFF_NOACC, 0},
     {"ACC", IFF_NOACC, 1},
 #endif
-#ifdef IFF_OACTIVE             /* Transmission in progress.  */
-    {"OACTIVE", IFF_OACTIVE},
-#endif
 #ifdef IFF_NOSR8025            /* No source route 802.5.  */
-    {"NOSR8025", IFF_NOSR8025},
+    {"NOSR8025", IFF_NOSR8025, 0},
     {"SR8025", IFF_NOSR8025, 1},
 #endif
 #ifdef IFF_CKO_ETC             /* Interface supports trailer checksum.  */
-    {"CKO_ETC", IFF_CKO_ETC},
+    {"CKO_ETC", IFF_CKO_ETC, 0},
 #endif
 #ifdef IFF_AR_SR8025           /* All routes broadcast for ARP 8025.  */
-    {"AR_SR8025", IFF_AR_SR8025},
+    {"AR_SR8025", IFF_AR_SR8025, 0},
 #endif
 #ifdef IFF_ALT_SR8025          /* Alternating no rif, rif for ARP on.  */
-    {"ALT_SR8025", IFF_ALT_SR8025},
+    {"ALT_SR8025", IFF_ALT_SR8025, 0},
 #endif
     /* Defined on OSF 4.0g systems.  */
 #ifdef IFF_PFCOPYALL           /* PFILT gets packets to this host.  */
-    {"PFCOPYALL", IFF_PFCOPYALL},
+    {"PFCOPYALL", IFF_PFCOPYALL, 0},
 #endif
 #ifdef IFF_UIOMOVE             /* DART.  */
-    {"UIOMOVE", IFF_UIOMOVE},
+    {"UIOMOVE", IFF_UIOMOVE, 0},
 #endif
 #ifdef IFF_PKTOK               /* DART.  */
-    {"PKTOK", IFF_PKTOK},
+    {"PKTOK", IFF_PKTOK, 0},
 #endif
 #ifdef IFF_SOCKBUF             /* DART.  */
-    {"SOCKBUF", IFF_SOCKBUF},
+    {"SOCKBUF", IFF_SOCKBUF, 0},
 #endif
 #ifdef IFF_VAR_MTU             /* Interface supports variable MTUs.  */
-    {"VAR_MTU", IFF_VAR_MTU},
+    {"VAR_MTU", IFF_VAR_MTU, 0},
 #endif
 #ifdef IFF_NOCHECKSUM          /* No checksums needed (reliable media).  */
-    {"NOCHECKSUM", IFF_NOCHECKSUM},
+    {"NOCHECKSUM", IFF_NOCHECKSUM, 0},
     {"CHECKSUM", IFF_NOCHECKSUM, 1},
 #endif
 #ifdef IFF_MULTINET            /* Multiple networks on interface.  */
-    {"MULTINET", IFF_MULTINET},
+    {"MULTINET", IFF_MULTINET, 0},
 #endif
 #ifdef IFF_VMIFNET             /* Used to identify a virtual MAC address.  */
-    {"VMIFNET", IFF_VMIFNET},
+    {"VMIFNET", IFF_VMIFNET, 0},
 #endif
 #if defined IFF_D1 && defined IFF_SNAP
 # if IFF_D1 == IFF_SNAP
     /* IFF_SNAP == IFF_D1 on OSF 4.0g systems.  This entry is used as a
        fallback for if_flagtoname conversion, if no relevant EXPECT_
        macro is specified to figure out which one is meant.  */
-    {"D1/SNAP", IFF_D2},
+    {"D1/SNAP", IFF_D2, 0},
 # endif
 #endif
 #ifdef IFF_D2                  /* Flag is specific to device.  */
-    {"D2", IFF_D2},
+    {"D2", IFF_D2, 0},
 #endif
 #ifdef IFF_SNAP                        /* Ethernet driver outputs SNAP header. 
 */
-    {"SNAP", IFF_SNAP},
-#endif
-#ifdef IFF_D2                  /* Flag is specific to device.  */
-    {"D2", IFF_D2},
+    {"SNAP", IFF_SNAP, 0},
 #endif
-    { NULL }
+    { NULL, 0, 0}
   };
 
 static int
@@ -434,7 +428,7 @@ static struct if_flag_char flag_char_tab[] = {
 #ifdef IFF_UP
   { IFF_UP,          'U' },
 #endif
-  { 0 }
+  { 0, 0 }
 };
 
 void
diff --git a/ifconfig/ifconfig.c b/ifconfig/ifconfig.c
index 9cef95f..a8abdb1 100644
--- a/ifconfig/ifconfig.c
+++ b/ifconfig/ifconfig.c
@@ -72,7 +72,7 @@ main (int argc, char *argv[])
            continue;
 
          /* Use ERR as a marker of previous output.
-          * It will never mix with a call to configure_if().  */
+          * It will never interfere with a call to configure_if().  */
          if (err++)
            putchar (' ');
          printf ("%s", ifp->name);
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 095d566..c49163d 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -37,6 +37,9 @@
 
 #include <sys/socket.h>
 #include <net/if.h>
+
+#include <unused-parameter.h>
+
 #include "ifconfig.h"
 
 /* List available interfaces.  */
@@ -45,6 +48,10 @@ int list_mode;
 /* Be verbose about actions.  */
 int verbose;
 
+/* Flags asked for, possibly still pending application.  */
+int pending_setflags;
+int pending_clrflags;
+
 /* Array of all interfaces on the command line.  */
 struct ifconfig *ifs;
 
@@ -54,6 +61,7 @@ int nifs;
 static struct ifconfig ifconfig_initializer = {
   NULL,                                /* name */
   0,                           /* valid */
+  NULL, NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0
 };
 
 struct format formats[] = {
@@ -190,7 +198,7 @@ struct format formats[] = {
    "${newline}"
    "}"
    "${exit}{0}"},
-  {0, 0}
+  {NULL, NULL, NULL}
 };
 
 /* Default format.  */
@@ -208,39 +216,43 @@ enum {
 };
 
 static struct argp_option argp_options[] = {
+#define GRP 10
   { "verbose", 'v', NULL, 0,
-    "output information when configuring interface" },
+    "output information when configuring interface", GRP },
   { "all", 'a', NULL, 0,
-    "display all available interfaces" },
+    "display all available interfaces", GRP },
   { "interface", 'i', "NAME", 0,
-    "configure network interface NAME" },
+    "configure network interface NAME", GRP },
   { "address", 'A', "ADDR", 0,
-    "set interface address to ADDR" },
+    "set interface address to ADDR", GRP },
   { "netmask", 'm', "MASK", 0,
-    "set netmask to MASK" },
+    "set netmask to MASK", GRP },
   { "dstaddr", 'd', "ADDR", 0,
-    "set destination (peer) address to ADDR" },
-  { "peer", 'p', "ADDR", OPTION_ALIAS },
+    "set destination (peer) address to ADDR", GRP },
+  { "peer", 'p', "ADDR", OPTION_ALIAS,
+    "synonym for dstaddr", GRP },
   { "broadcast", 'B', "ADDR", 0,
-    "set broadcast address to ADDR" },
-  { "brdaddr", 'b', NULL, OPTION_ALIAS, }, /* FIXME: Do we really need it? */
+    "set broadcast address to ADDR", GRP },
+  { "brdaddr", 'b', NULL, OPTION_ALIAS,
+    "synonym for broadcast", GRP }, /* FIXME: Do we really need it? */
   { "mtu", 'M', "N", 0,
-    "set mtu of interface to N" },
+    "set mtu of interface to N", GRP },
   { "metric", METRIC_OPTION, "N", 0,
-    "set metric of interface to N" },
+    "set metric of interface to N", GRP },
   { "format", FORMAT_OPTION, "FORMAT", 0,
-    "select output format; set to `help' for info" },
+    "select output format; set to `help' for info", GRP },
   { "up", UP_OPTION, NULL, 0,
-    "activate the interface (default if address is given)" },
+    "activate the interface (default if address is given)", GRP },
   { "down", DOWN_OPTION, NULL, 0,
-    "shut the interface down" },
+    "shut the interface down", GRP },
   { "flags", 'F', "FLAG[,FLAG...]", 0,
-    "set interface flags" },
+    "set interface flags", GRP },
   { "list", 'l', NULL, 0,
-    "list available or selected interfaces" },
+    "list available or selected interfaces", GRP },
   { "short", 's', NULL, 0,
-    "short output format" },
-  { NULL }
+    "short output format", GRP },
+#undef GRP
+  { NULL, 0, NULL, 0, NULL, 0 }
 };
 
 const char doc[] = "Configure network interfaces.";
@@ -337,12 +349,19 @@ void parse_opt_set_af (struct ifconfig *ifp, char *af)
 }
 
 void
-parse_opt_set_flag (struct ifconfig *ifp, int flag, int rev)
+parse_opt_set_flag (struct ifconfig *ifp _GL_UNUSED_PARAMETER,
+                   int flag, int rev)
 {
   if (rev)
-    ifp->clrflags |= flag;
+    {
+      pending_clrflags |= flag;
+      pending_setflags &= ~flag;
+    }
   else
-    ifp->setflags |= flag;
+    {
+      pending_setflags |= flag;
+      pending_clrflags &= ~flag;
+    }
 }
 
 void
@@ -452,6 +471,8 @@ parse_opt_finalize (struct ifconfig *ifp)
     {
       ifp->valid = IF_VALID_FORMAT;
       ifp->format = default_format;
+      ifp->setflags |= pending_setflags;
+      ifp->clrflags |= pending_clrflags;
     }
 }
 
@@ -541,7 +562,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
 }
 
 static char *
-default_help_filter (int key, const char *text, void *input)
+default_help_filter (int key, const char *text,
+                    void *input _GL_UNUSED_PARAMETER)
 {
   char *s;
 
@@ -565,7 +587,8 @@ static struct argp argp =
     NULL,
     doc,
     NULL,
-    default_help_filter
+    default_help_filter,
+    NULL
   };
 
 static int
diff --git a/ifconfig/options.h b/ifconfig/options.h
index bc2060d..1cbfdb7 100644
--- a/ifconfig/options.h
+++ b/ifconfig/options.h
@@ -65,6 +65,9 @@ extern struct format formats[];
 extern int all_option;
 extern int ifs_cmdline;
 
+extern int pending_setflags;
+extern int pending_clrflags;
+
 /* Array of interfaces mentioned on the command line.  */
 extern struct ifconfig *ifs;
 extern int nifs;
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index e41582c..5dbd8c5 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -47,6 +47,7 @@
 #include <arpa/inet.h>
 #include "ifconfig.h"
 #include "xalloc.h"
+#include <unused-parameter.h>
 
 FILE *ostream;                 /* Either stdout or stderror.  */
 int column_stdout;             /* The column position of the cursor on stdout. 
 */
@@ -114,7 +115,7 @@ struct format_handle format_handles[] = {
 /* Various helper functions to get the job done.  */
 
 void
-put_char (format_data_t form, char c)
+put_char (format_data_t form _GL_UNUSED_PARAMETER, char c)
 {
   switch (c)
     {
@@ -142,7 +143,8 @@ put_string (format_data_t form, const char *s)
 }
 
 void
-put_int (format_data_t form, int argc, char *argv[], int nr)
+put_int (format_data_t form _GL_UNUSED_PARAMETER,
+        int argc, char *argv[], int nr)
 {
   char *fmt;
   if (argc > 0)
@@ -198,7 +200,8 @@ put_int (format_data_t form, int argc, char *argv[], int nr)
 }
 
 void
-put_ulong (format_data_t form, int argc, char *argv[], unsigned long value)
+put_ulong (format_data_t form _GL_UNUSED_PARAMETER,
+          int argc, char *argv[], unsigned long value)
 {
   char *fmt;
   if (argc > 0)
@@ -337,7 +340,8 @@ put_flags (format_data_t form, int argc, char *argv[], 
short flags)
 }
 
 void
-put_flags_short (format_data_t form, int argc, char *argv[], short flags)
+put_flags_short (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+                char *argv[] _GL_UNUSED_PARAMETER, short flags)
 {
   char buf[IF_FORMAT_FLAGS_BUFSIZE];
   if_format_flags (flags, buf, sizeof buf);
@@ -368,7 +372,9 @@ format_handler (const char *name, format_data_t form, int 
argc, char *argv[])
 }
 
 void
-fh_nothing (format_data_t form, int argc, char *argv[])
+fh_nothing (format_data_t form _GL_UNUSED_PARAMETER,
+           int argc _GL_UNUSED_PARAMETER,
+           char *argv[] _GL_UNUSED_PARAMETER)
 {
 }
 
@@ -427,13 +433,15 @@ fh_foreachformat (format_data_t form, int argc, char 
*argv[])
 }
 
 void
-fh_newline (format_data_t form, int argc, char *argv[])
+fh_newline (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+           char *argv[] _GL_UNUSED_PARAMETER)
 {
   put_char (form, '\n');
 }
 
 void
-fh_tabulator (format_data_t form, int argc, char *argv[])
+fh_tabulator (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+             char *argv[] _GL_UNUSED_PARAMETER)
 {
   put_char (form, '\t');
 }
@@ -588,13 +596,15 @@ fh_error (format_data_t form, int argc, char *argv[])
 }
 
 void
-fh_progname (format_data_t form, int argc, char *argv[])
+fh_progname (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+            char *argv[] _GL_UNUSED_PARAMETER)
 {
   put_string (form, program_name);
 }
 
 void
-fh_exit (format_data_t form, int argc, char *argv[])
+fh_exit (format_data_t form _GL_UNUSED_PARAMETER,
+        int argc, char *argv[])
 {
   int err = 0;
 
@@ -605,7 +615,8 @@ fh_exit (format_data_t form, int argc, char *argv[])
 }
 
 void
-fh_name (format_data_t form, int argc, char *argv[])
+fh_name (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+        char *argv[] _GL_UNUSED_PARAMETER)
 {
   put_string (form, form->name);
 }
@@ -617,7 +628,8 @@ fh_index_query (format_data_t form, int argc, char *argv[])
 }
 
 void
-fh_index (format_data_t form, int argc, char *argv[])
+fh_index (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+         char *argv[] _GL_UNUSED_PARAMETER)
 {
   int indx = if_nametoindex (form->name);
 
diff --git a/ifconfig/system/bsd.c b/ifconfig/system/bsd.c
index 59a792a..adf8945 100644
--- a/ifconfig/system/bsd.c
+++ b/ifconfig/system/bsd.c
@@ -28,6 +28,8 @@
 #include <net/if_dl.h>
 #include <netinet/if_ether.h>
 #include <ifaddrs.h>
+
+#include <unused-parameter.h>
 
 
 /* Output format stuff.  */
@@ -44,7 +46,9 @@ NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] "
 struct argp_child system_argp_child;
 
 int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
+                 char option _GL_UNUSED_PARAMETER,
+                 char *optarg _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
@@ -139,7 +143,9 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc, 
char *argv[])
 }
 
 int
-system_configure (int sfd, struct ifreq *ifr, struct system_ifconfig *ifs)
+system_configure (int sfd _GL_UNUSED_PARAMETER,
+                 struct ifreq *ifr _GL_UNUSED_PARAMETER,
+                 struct system_ifconfig *ifs _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
@@ -184,7 +190,8 @@ system_fh_hwaddr_query (format_data_t form, int argc, char 
*argv[])
 }
 
 void
-system_fh_hwaddr (format_data_t form, int argc, char *argv[])
+system_fh_hwaddr (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+                 char *argv[] _GL_UNUSED_PARAMETER)
 {
   ESTABLISH_IFADDRS
   if (!ifp)
@@ -223,7 +230,8 @@ system_fh_hwtype_query (format_data_t form, int argc, char 
*argv[])
 }
 
 void
-system_fh_hwtype (format_data_t form, int argc, char *argv[])
+system_fh_hwtype (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+                 char *argv[] _GL_UNUSED_PARAMETER)
 {
   ESTABLISH_IFADDRS
   if (!ifp)
diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index 95c0e60..d676af5 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -45,6 +45,7 @@
 #include <linux/if_ether.h>
 
 #include <read-file.h>
+#include <unused-parameter.h>
 
 #include "../ifconfig.h"
 
@@ -52,22 +53,28 @@
 /* ARPHRD stuff.  */
 
 static void
-print_hwaddr_ether (format_data_t form, unsigned char *data)
+print_hwaddr_ether (format_data_t form _GL_UNUSED_PARAMETER,
+                   unsigned char *data)
 {
   *column += printf ("%02X:%02X:%02X:%02X:%02X:%02X",
                     data[0], data[1], data[2], data[3], data[4], data[5]);
+  had_output = 1;
 }
 
 static void
-print_hwaddr_arcnet (format_data_t form, unsigned char *data)
+print_hwaddr_arcnet (format_data_t form _GL_UNUSED_PARAMETER,
+                    unsigned char *data)
 {
   *column += printf ("%02X", data[0]);
+  had_output = 1;
 }
 
 static void
-print_hwaddr_dlci (format_data_t form, unsigned char *data)
+print_hwaddr_dlci (format_data_t form _GL_UNUSED_PARAMETER,
+                  unsigned char *data)
 {
   *column += printf ("%i", *((short *) data));
+  had_output = 1;
 }
 
 static void
@@ -81,22 +88,29 @@ print_hwaddr_ax25 (format_data_t form, unsigned char *data)
     }
   i = (data[6] & 0x1E) >> 1;
   if (i)
-    *column += printf ("-%i", i);
+    {
+      *column += printf ("-%i", i);
+      had_output = 1;
+    }
 #undef mangle
 }
 
 static void
-print_hwaddr_irda (format_data_t form, unsigned char *data)
+print_hwaddr_irda (format_data_t form _GL_UNUSED_PARAMETER,
+                  unsigned char *data)
 {
   *column += printf ("%02X:%02X:%02X:%02X",
                     data[3], data[2], data[1], data[0]);
+  had_output = 1;
 }
 
 static void
-print_hwaddr_rose (format_data_t form, unsigned char *data)
+print_hwaddr_rose (format_data_t form _GL_UNUSED_PARAMETER,
+                  unsigned char *data)
 {
   *column += printf ("%02X%02X%02X%02X%02X",
                     data[0], data[1], data[2], data[3], data[4]);
+  had_output = 1;
 }
 
 struct arphrd_symbol
@@ -535,7 +549,8 @@ system_fh_hwaddr_query (format_data_t form, int argc, char 
*argv[])
 }
 
 void
-system_fh_hwaddr (format_data_t form, int argc, char *argv[])
+system_fh_hwaddr (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+                 char *argv[] _GL_UNUSED_PARAMETER)
 {
 #ifdef SIOCGIFHWADDR
   if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
@@ -571,7 +586,8 @@ system_fh_hwtype_query (format_data_t form, int argc, char 
*argv[])
 }
 
 void
-system_fh_hwtype (format_data_t form, int argc, char *argv[])
+system_fh_hwtype (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+                 char *argv[] _GL_UNUSED_PARAMETER)
 {
 #ifdef SIOCGIFHWADDR
   if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
@@ -693,8 +709,8 @@ system_parse_opt_set_txqlen (struct ifconfig *ifp, char 
*arg)
 
 static struct argp_option linux_argp_options[] = {
   { "txqlen", 'T', "N", 0,
-    "set transmit queue length to N" },
-  { NULL }
+    "set transmit queue length to N", 0 },
+  { NULL, 0, NULL, 0, NULL, 0 }
 };
 
 static error_t
@@ -713,7 +729,8 @@ linux_argp_parser (int key, char *arg, struct argp_state 
*state)
   return 0;
 }
 
-static struct argp linux_argp = { linux_argp_options, linux_argp_parser };
+static struct argp linux_argp =
+  { linux_argp_options, linux_argp_parser, NULL, NULL, NULL, NULL, NULL };
 
 struct argp_child system_argp_child = {
   &linux_argp,
diff --git a/ifconfig/system/solaris.c b/ifconfig/system/solaris.c
index 8a0b58f..c4da17e 100644
--- a/ifconfig/system/solaris.c
+++ b/ifconfig/system/solaris.c
@@ -45,6 +45,8 @@
 #include <net/if_arp.h>
 #include <netinet/if_ether.h>
 
+#include <unused-parameter.h>
+
 #include "../ifconfig.h"
 
 
@@ -62,7 +64,9 @@ NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] "
 struct argp_child system_argp_child;
 
 int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
+                 char option _GL_UNUSED_PARAMETER,
+                 char *optarg _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
@@ -165,7 +169,7 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
 # ifndef SIOCSIFTXQLEN
       error (0, 0, "don't know how to set the txqlen on this system");
       return -1;
-# else
+# else /* SIOCSIFTXQLEN */
       int err = 0;
 
       ifr->ifr_qlen = ifs->txqlen;
@@ -175,10 +179,14 @@ system_configure (int sfd, struct ifreq *ifr, struct 
system_ifconfig *ifs)
       if (verbose)
        printf ("Set txqlen value of `%s' to `%i'.\n",
                ifr->ifr_name, ifr->ifr_qlen);
-# endif
+# endif /* SIOCSIFTXQLEN */
     }
+#else /* !IF_VALID_TXQLEN */
+  (void) sfd;
+  (void) ifr;
+  (void) ifs;
+#endif /* !IF_VALID_TXQLEN */
   return 0;
-#endif
 }
 
 
diff --git a/ifconfig/system/solaris.h b/ifconfig/system/solaris.h
index 64898ff..ed06d57 100644
--- a/ifconfig/system/solaris.h
+++ b/ifconfig/system/solaris.h
@@ -28,9 +28,12 @@
 
 
 /* XXX: Gross. Have autoconf check and put in system.h or so.
-   The correctness is documented in Solaris 2.7, if_tcp(7p).  */
+   The correctness is documented in Solaris 2.7, if_tcp(7p).
+   At least OpenSolaris and later systems do provide ifr_mtu.  */
 
-# define ifr_mtu ifr_metric
+# ifndef HAVE_STRUCT_IFREQ_IFR_MTU
+#  define ifr_mtu ifr_metric
+# endif /* !HAVE_STRUCT_IFREQ_IFR_MTU */
 
 
 /* Option support.  */

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=72e61402af942ed672b3dd6e937aa4854db330ae


commit 72e61402af942ed672b3dd6e937aa4854db330ae
Author: Mats Erik Andersson <address@hidden>
Date:   Wed Dec 5 00:24:26 2012 +0100

    ifconfig: Parse command line for BSD.

diff --git a/ChangeLog b/ChangeLog
index d40e5bb..8665f35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-12-04  Mats Erik Andersson  <address@hidden>
+
+       * ifconfig/system/bsd.c (system_help): Update.
+       (system_parse_opt_rest): Populate function with
+       parser and actions for command line arguments.
+
+       * ifconfig/system/solaris.c (system_help): Update.
+       (system_parse_opt_rest): Implement actions for the
+       arguments "up" and "down" of an interface.
+
 2012-12-03  Mats Erik Andersson  <address@hidden>
 
        ifconfig: Audit displaying of metrics.
diff --git a/ifconfig/COMPATIBILITY b/ifconfig/COMPATIBILITY
index 81302fb..5621434 100644
--- a/ifconfig/COMPATIBILITY
+++ b/ifconfig/COMPATIBILITY
@@ -27,6 +27,7 @@ hpux10.20
 
 
 sparc-sun-solaris-2.7
+OpenSolaris
 
        Uses the output format `unix'.
 
@@ -34,3 +35,9 @@ sparc-sun-solaris-2.7
 alphaev56-dec-osf4.0g
 
        Uses the output format `osf'.
+
+
+*BSD
+
+       Uses output format `unix'.  Basic functionality for
+       DragonflyBSD, FreeBSD, NetBSD, and OpenBSD.
diff --git a/ifconfig/system/bsd.c b/ifconfig/system/bsd.c
index e8d0fff..59a792a 100644
--- a/ifconfig/system/bsd.c
+++ b/ifconfig/system/bsd.c
@@ -1,4 +1,4 @@
-/* generic.c -- generic system code for ifconfig
+/* bsd.c -- BSD specific code for ifconfig
   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
   2010, 2011, 2012 Free Software Foundation, Inc.
 
@@ -38,7 +38,8 @@ const char *system_default_format = "unix";
 /* Argument parsing stuff.  */
 
 const char *system_help = "\
-NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] [metric N] [mtu N]";
+NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] "
+"[metric N] [mtu N] [up|down]";
 
 struct argp_child system_argp_child;
 
@@ -51,7 +52,90 @@ system_parse_opt (struct ifconfig **ifp, char option, char 
*optarg)
 int
 system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
 {
-  return 0;
+  int i = 0;
+  enum
+  {
+    EXPECT_NOTHING,
+    EXPECT_BROADCAST,
+    EXPECT_NETMASK,
+    EXPECT_METRIC,
+    EXPECT_MTU
+  } expect = EXPECT_NOTHING;
+
+  *ifp = parse_opt_new_ifs (argv[0]);
+
+  while (++i < argc)
+    {
+      switch (expect)
+       {
+       case EXPECT_BROADCAST:
+         parse_opt_set_brdaddr (*ifp, argv[i]);
+         break;
+
+       case EXPECT_NETMASK:
+         parse_opt_set_netmask (*ifp, argv[i]);
+         break;
+
+       case EXPECT_MTU:
+         parse_opt_set_mtu (*ifp, argv[i]);
+         break;
+
+       case EXPECT_METRIC:
+         parse_opt_set_metric (*ifp, argv[i]);
+         break;
+
+       case EXPECT_NOTHING:
+         break;
+       }
+
+      if (expect != EXPECT_NOTHING)
+       expect = EXPECT_NOTHING;
+      else if (!strcmp (argv[i], "broadcast"))
+       expect = EXPECT_BROADCAST;
+      else if (!strcmp (argv[i], "netmask"))
+       expect = EXPECT_NETMASK;
+      else if (!strcmp (argv[i], "metric"))
+       expect = EXPECT_METRIC;
+      else if (!strcmp (argv[i], "mtu"))
+       expect = EXPECT_MTU;
+      else if (!strcmp (argv[i], "up"))
+       parse_opt_set_flag (*ifp, IFF_UP | IFF_RUNNING, 0);
+      else if (!strcmp (argv[i], "down"))
+       parse_opt_set_flag (*ifp, IFF_UP, 1);
+      else
+       {
+         /* Recognize AF here.  */
+         /* Also alias, -alias, promisc, -promisc,
+            create, destroy, monitor, -monitor.  */
+         if (!((*ifp)->valid & IF_VALID_ADDR))
+           parse_opt_set_address (*ifp, argv[i]);
+         else if (!((*ifp)->valid & IF_VALID_DSTADDR))
+           parse_opt_set_dstaddr (*ifp, argv[i]);
+       }
+    }
+
+  switch (expect)
+    {
+    case EXPECT_BROADCAST:
+      error (0, 0, "option `broadcast' requires an argument");
+      break;
+
+    case EXPECT_NETMASK:
+      error (0, 0, "option `netmask' requires an argument");
+      break;
+
+    case EXPECT_METRIC:
+      error (0, 0, "option `metric' requires an argument");
+      break;
+
+    case EXPECT_MTU:
+      error (0, 0, "option `mtu' requires an argument");
+      break;
+
+    case EXPECT_NOTHING:
+      break;
+    }
+  return expect == EXPECT_NOTHING;
 }
 
 int
diff --git a/ifconfig/system/solaris.c b/ifconfig/system/solaris.c
index 0d53694..8a0b58f 100644
--- a/ifconfig/system/solaris.c
+++ b/ifconfig/system/solaris.c
@@ -56,7 +56,8 @@ const char *system_default_format = "unix";
 /* Argument parsing stuff.  */
 
 const char *system_help = "\
-NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] [metric N] [mtu N]";
+NAME [ADDR [DSTADDR]] [broadcast BRDADDR] [netmask MASK] "
+"[metric N] [mtu N] [up|down]";
 
 struct argp_child system_argp_child;
 
@@ -115,10 +116,13 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc, 
char *argv[])
        expect = EXPECT_METRIC;
       else if (!strcmp (argv[i], "mtu"))
        expect = EXPECT_MTU;
+      else if (!strcmp (argv[i], "up"))
+       parse_opt_set_flag (*ifp, IFF_UP | IFF_RUNNING, 0);
+      else if (!strcmp (argv[i], "down"))
+       parse_opt_set_flag (*ifp, IFF_UP, 1);
       else
        {
          /* Recognize AF here.  */
-         /* Recognize up/down.  */
          /* Also auto-revarp, trailers, -trailers,
             private, -private, arp, -arp, plumb, unplumb.  */
          if (!((*ifp)->valid & IF_VALID_ADDR))

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=0d19e38f4f71e2137d88b4aafa917f519fc70e9d


commit 0d19e38f4f71e2137d88b4aafa917f519fc70e9d
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Dec 3 23:20:27 2012 +0100

    ifconfig: Displaying of interface metric.

diff --git a/ChangeLog b/ChangeLog
index 89efac9..d40e5bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2012-12-03  Mats Erik Andersson  <address@hidden>
 
+       ifconfig: Audit displaying of metrics.
+       The portable display is to supress metric naught.
+
+       * ifconfig/printif.c (fh_metric_query) [SIOCGIFMETRIC]:
+       Add the further condition `form->ifr->ifr_metric > 0'
+       (fh_metric) [SIOCGIFMETRIC]: Do not report value 0 of
+       `form->ifr->ifr_metric' as 1.
+       * ifconfig/system/bsd.c (system_fh_metric): Remove.
+       * ifconfig/system/bsd.h (SYSTEM_FORMAT_HANDLER):
+       Delete key "metric".
+       (system_fh_metric): Remove prototype.
+
+       Implement exceptional handler for GNU/Linux.
+
+       * ifconfig/system/linux.c (system_fh_metric_query)
+       (system_fh_metric): New functions.
+       * ifconfig/system/linux.h (SYSTEM_FORMAT_HANDLER):
+       Add new keys "metric?" and "metric".
+       (system_fh_metric_query, system_fh_metric):
+       New prototypes.
+
+2012-12-03  Mats Erik Andersson  <address@hidden>
+
        ifconfig.sh: Avoid substring matches.
 
        * tests/ifconfig.sh (LO): Assign inside a loop,
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index 5bd93b7..e41582c 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -788,11 +788,15 @@ fh_mtu (format_data_t form, int argc, char *argv[])
 #endif
 }
 
+/* The portable behaviour is to display strictly positive
+ * metrics, but to supress the default value naught.
+ */
 void
 fh_metric_query (format_data_t form, int argc, char *argv[])
 {
 #ifdef SIOCGIFMETRIC
-  if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) >= 0)
+  if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) >= 0
+      && form->ifr->ifr_metric > 0)
     select_arg (form, argc, argv, 0);
   else
 #endif
@@ -808,8 +812,7 @@ 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 ? form->ifr->ifr_metric : 1);
+    put_int (form, argc, argv, form->ifr->ifr_metric);
 #else
   *column += printf ("(not available)");
   had_output = 1;
diff --git a/ifconfig/system/bsd.c b/ifconfig/system/bsd.c
index 4b337ed..e8d0fff 100644
--- a/ifconfig/system/bsd.c
+++ b/ifconfig/system/bsd.c
@@ -169,19 +169,3 @@ system_fh_hwtype (format_data_t form, int argc, char 
*argv[])
        put_string (form, "(unknown hwtype)");
     }
 }
-
-void
-system_fh_metric (format_data_t form, int argc, char *argv[])
-{
-#ifdef SIOCGIFMETRIC
-  if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) < 0)
-    error (EXIT_FAILURE, errno,
-          "SIOCGIFMETRIC failed for interface `%s'",
-          form->ifr->ifr_name);
-  else
-    put_int (form, argc, argv, form->ifr->ifr_metric);
-#else
-  *column += printf ("(not available)");
-  had_output = 1;
-#endif
-}
diff --git a/ifconfig/system/bsd.h b/ifconfig/system/bsd.h
index 49dcfaa..75cdae1 100644
--- a/ifconfig/system/bsd.h
+++ b/ifconfig/system/bsd.h
@@ -61,13 +61,11 @@ struct system_ifconfig
   {"hwaddr?", system_fh_hwaddr_query}, \
   {"hwaddr", system_fh_hwaddr}, \
   {"hwtype?", system_fh_hwtype_query}, \
-  {"hwtype", system_fh_hwtype}, \
-  {"metric", system_fh_metric},
+  {"hwtype", system_fh_hwtype},
 
 void system_fh_hwaddr_query (format_data_t form, int argc, char *argv[]);
 void system_fh_hwaddr (format_data_t form, int argc, char *argv[]);
 void system_fh_hwtype_query (format_data_t form, int argc, char *argv[]);
 void system_fh_hwtype (format_data_t form, int argc, char *argv[]);
-void system_fh_metric (format_data_t form, int argc, char *argv[]);
 
 #endif /* IFCONFIG_SYSTEM_BSD_H */
diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index c7f3638..95c0e60 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -594,6 +594,38 @@ system_fh_hwtype (format_data_t form, int argc, char 
*argv[])
 #endif
 }
 
+/* Accept every value of metric as printable.  The net-tools'
+ * implementation of ifconfig displays metric 0 as `1', so we
+ * aim at the same thing, even though all other unices disagree.
+ */
+void
+system_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, 0);
+  else
+#endif
+    select_arg (form, argc, argv, 1);
+}
+
+void
+system_fh_metric (format_data_t form, int argc, char *argv[])
+{
+#ifdef SIOCGIFMETRIC
+  if (ioctl (form->sfd, SIOCGIFMETRIC, form->ifr) < 0)
+    error (EXIT_FAILURE, errno,
+          "SIOCGIFMETRIC failed for interface `%s'",
+          form->ifr->ifr_name);
+  else
+    put_int (form, argc, argv,
+            form->ifr->ifr_metric ? form->ifr->ifr_metric : 1);
+#else
+  *column += printf ("(not available)");
+  had_output = 1;
+#endif
+}
+
 void
 system_fh_txqlen_query (format_data_t form, int argc, char *argv[])
 {
diff --git a/ifconfig/system/linux.h b/ifconfig/system/linux.h
index 5fe8906..50f2dde 100644
--- a/ifconfig/system/linux.h
+++ b/ifconfig/system/linux.h
@@ -51,6 +51,8 @@ struct system_ifconfig
   {"hwaddr", system_fh_hwaddr}, \
   {"hwtype?", system_fh_hwtype_query}, \
   {"hwtype", system_fh_hwtype}, \
+  {"metric?", system_fh_metric_query}, \
+  {"metric", system_fh_metric}, \
   {"txqlen?", system_fh_txqlen_query}, \
   {"txqlen", system_fh_txqlen}, \
   {"ifstat?", system_fh_ifstat_query}, \
@@ -82,6 +84,8 @@ void system_fh_hwaddr_query (format_data_t form, int argc, 
char *argv[]);
 void system_fh_hwaddr (format_data_t form, int argc, char *argv[]);
 void system_fh_hwtype_query (format_data_t form, int argc, char *argv[]);
 void system_fh_hwtype (format_data_t form, int argc, char *argv[]);
+void system_fh_metric_query (format_data_t form, int argc, char *argv[]);
+void system_fh_metric (format_data_t form, int argc, char *argv[]);
 void system_fh_txqlen_query (format_data_t form, int argc, char *argv[]);
 void system_fh_txqlen (format_data_t form, int argc, char *argv[]);
 

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=065f43884cfbc7ba1dc7639d4bd87a650fa05b33


commit 065f43884cfbc7ba1dc7639d4bd87a650fa05b33
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Dec 3 19:59:30 2012 +0100

    Small fixes.

diff --git a/ChangeLog b/ChangeLog
index 787dd48..89efac9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2012-12-03  Mats Erik Andersson  <address@hidden>
+
+       ifconfig.sh: Avoid substring matches.
+
+       * tests/ifconfig.sh (LO): Assign inside a loop,
+       after matching by `expr' against interface name.
+
+       Format string errors and warnings.
+
+       * ifconfig/options.c (parse_opt_flag_list):
+       Cast LEN as int for use as width in `%*.*s'.
+       * src/rcp.c (source): Use "%zd" instead of "%lld".
+       * src/rexecd.c (doit): Format "%d" for `pwd->pw_gid'.
+       * telnet/commands.c (ayt_status) [SIGINFO]:
+       Return status 1.
+       (help): Cast HELPIDENT as int for use as format width.
+
 2012-11-28  Mats Erik Andersson  <address@hidden>
 
        libinetutils.a: Build if_nametoindex(), if_nameindex(),
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 6e6317d..095d566 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -360,7 +360,8 @@ parse_opt_flag_list (struct ifconfig *ifp, const char *name)
        len = strlen (name);
 
       if ((mask = if_nametoflag (name, len, &rev)) == 0)
-       error (EXIT_FAILURE, 0, "unknown flag %*.*s", len, len, name);
+       error (EXIT_FAILURE, 0, "unknown flag %*.*s",
+              (int) len, (int) len, name);
       parse_opt_set_flag (ifp, mask, rev);
 
       name += len;
diff --git a/src/rcp.c b/src/rcp.c
index 0e97cbd..2a35112 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -731,7 +731,7 @@ source (int argc, char *argv[])
 #define RCP_MODEMASK   (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
       snprintf (buf, sizeof buf,
                (sizeof (stb.st_size) > sizeof (long)
-                ? "C%04o %lld %s\n"
+                ? "C%04o %zd %s\n"
                 : "C%04o %ld %s\n"),
                stb.st_mode & RCP_MODEMASK, stb.st_size, last);
       write (rem, buf, strlen (buf));
diff --git a/src/rexecd.c b/src/rexecd.c
index 32a2228..b7ff3b2 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -455,7 +455,7 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
 # ifdef WITH_PAM
       pam_rc = PAM_ABORT;
 # endif
-      syslog (LOG_DEBUG | LOG_AUTH, "initgroups(%s, %s): %m",
+      syslog (LOG_DEBUG | LOG_AUTH, "initgroups(%s, %d): %m",
              pwd->pw_name, pwd->pw_gid);
       die (EXIT_FAILURE, "Failed group protections.");
     }
diff --git a/telnet/commands.c b/telnet/commands.c
index 651b3e6..7c409a9 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -2427,8 +2427,9 @@ int
 ayt_status ()
 {
   call (status, "status", "notmuch", 0);
+  return 1;    /* not used */
 }
-#endif
+#endif /* SIGINFO */
 
 static void cmdrc (char *m1, char *m2);
 
@@ -3004,7 +3005,7 @@ help (int argc, char *argv[])
       for (c = cmdtab; c->name; c++)
        if (c->help)
          {
-           printf ("%-*s\t%s\n", HELPINDENT, c->name, c->help);
+           printf ("%-*s\t%s\n", (int) HELPINDENT, c->name, c->help);
          }
       return 0;
     }
diff --git a/tests/ifconfig.sh b/tests/ifconfig.sh
index dbb6e8e..8472e8e 100755
--- a/tests/ifconfig.sh
+++ b/tests/ifconfig.sh
@@ -70,8 +70,15 @@ fi
 
 # Locate the loopback interface.
 #
+# Avoid cases where `lo' is a substring
+# of another interface name, like for
+# `pflog0' of OpenBSD.
+#
 IF_LIST=`$IFCONFIG -l`
-LO=`expr "$IF_LIST" : '.*\(lo0\{0,\}\).*'`
+for nn in $IF_LIST; do
+    LO=`expr $nn : '\(lo0\{0,\}\).*'`
+    test -z "$LO" || break
+done
 
 if test -z "$LO"; then
     echo >&2 'Unable to locate loopback interface.  Failing.'

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

Summary of changes:
 ChangeLog                 |  116 ++++++++++++++++++++++++++++++++++++++++++
 configure.ac              |   11 ++--
 ifconfig/COMPATIBILITY    |    7 +++
 ifconfig/flags.c          |  104 ++++++++++++++++++--------------------
 ifconfig/ifconfig.c       |    2 +-
 ifconfig/options.c        |   74 ++++++++++++++++++---------
 ifconfig/options.h        |    3 +
 ifconfig/printif.c        |   43 +++++++++++-----
 ifconfig/system/bsd.c     |  122 ++++++++++++++++++++++++++++++++++++---------
 ifconfig/system/bsd.h     |    4 +-
 ifconfig/system/linux.c   |   71 ++++++++++++++++++++++----
 ifconfig/system/linux.h   |    4 ++
 ifconfig/system/solaris.c |   24 +++++++--
 ifconfig/system/solaris.h |    7 ++-
 src/rcp.c                 |    2 +-
 src/rexecd.c              |    2 +-
 telnet/commands.c         |    5 +-
 tests/ifconfig.sh         |    9 +++-
 18 files changed, 460 insertions(+), 150 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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