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_2-9-g5f8a021


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-9-g5f8a021
Date: Sat, 22 Feb 2014 20:51: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  5f8a021b32df3d31cd98f6c85ad7c8f2b8308506 (commit)
      from  e2fbb2cc6f8832e909e2b970e82211af92ed3e91 (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=5f8a021b32df3d31cd98f6c85ad7c8f2b8308506


commit 5f8a021b32df3d31cd98f6c85ad7c8f2b8308506
Author: Mats Erik Andersson <address@hidden>
Date:   Sat Feb 22 21:46:28 2014 +0100

    ifconfig: Allow flags richer than 16 bits.
    
    Contemporary systems are not restricted to flags within
    a 16 bit span, notably FreeBSD and GNU/kFreeBSD.  Support
    this wider range and incorporate three new flags.

diff --git a/ChangeLog b/ChangeLog
index cdd8e77..c6045f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2014-02-22  Mats Erik Andersson  <address@hidden>
+
+       ifconfig: Allow flags richer than 16 bits.
+       Systems like GNU/kFreeBSD and FreeBSD use two `short int'
+       to represent interface flags.  Adapt to this fact.
+
+       * ifconfig/changeif.c (set_flags): Apply mask 0xffff to flags.
+       [ifr_flagshigh]: Calculate flag changes also on ifr_flagshigh.
+       * ifconfig/flags.c [IFF_PPROMISC] (if_flags): Add user land
+       setable flag "PROMISC".
+       [IFF_MONITOR] (if_flags): Add flag "MONITOR".
+       [IFF_STATICARP] (if_flags): Add flag "STATICARP".
+       [IFF_STATICARP] (flag_char_tab): Add short flag 's'.
+       [IFF_MONITOR] (flag_char_tab): Add short flag 'm'.
+       * ifconfig/options.c (formats) <unix>: Print flags numerically
+       using format string "%x".
+       * ifconfig/printif.c (put_flags): Change signature.  New type
+       of F is `unsigned int'.  New variable UFLAGS.  Work with UFLAGS,
+       not `flags'.
+       (put_flags_short): New signature.
+       [SIOCGIFFLAGS] (fh_ifdisplay_query, fh_brdaddr_query)
+       (fh_dstaddr_query, fh_flags): New variable UFLAGS, replacing
+       `form->ifr->ifr_flags'.
+       * ifconfig/printif.h (put_flags): Change prototype.
+
 2014-02-15  Mats Erik Andersson  <address@hidden>
 
        ifconfig: No listing of unchangeable flags.
diff --git a/ifconfig/changeif.c b/ifconfig/changeif.c
index 391513f..0bc99ac 100644
--- a/ifconfig/changeif.c
+++ b/ifconfig/changeif.c
@@ -247,7 +247,14 @@ set_flags (int sfd, struct ifreq *ifr, int setflags, int 
clrflags)
       error (0, errno, "SIOCGIFFLAGS failed");
       return -1;
     }
-  ifr->ifr_flags = (tifr.ifr_flags | setflags) & ~clrflags;
+  /* Some systems, notably FreeBSD, use two short integers.  */
+  ifr->ifr_flags = (tifr.ifr_flags | setflags) & ~clrflags & 0xffff;
+
+# ifdef ifr_flagshigh
+  ifr->ifr_flagshigh = (tifr.ifr_flagshigh | (setflags >> 16))
+                      & ~(clrflags >> 16);
+# endif /* ifr_flagshigh */
+
   if (ioctl (sfd, SIOCSIFFLAGS, ifr) < 0)
     {
       error (0, errno, "SIOCSIFFLAGS failed");
diff --git a/ifconfig/flags.c b/ifconfig/flags.c
index ea79426..19777a9 100644
--- a/ifconfig/flags.c
+++ b/ifconfig/flags.c
@@ -67,6 +67,12 @@ struct if_flag
     {"NOARP", IFF_NOARP, 0},
     {"ARP", IFF_NOARP, 1},
 #endif
+/* Keep IFF_PPROMISC prior to IFF_PROMISC
+ * for precedence in parsing.
+ */
+#ifdef IFF_PPROMISC            /* User accessible promiscuous mode.  */
+    {"PROMISC", IFF_PPROMISC, 0},
+#endif
 #ifdef IFF_PROMISC             /* Receive all packets.  */
     {"PROMISC", IFF_PROMISC, 0},
 #endif
@@ -212,6 +218,12 @@ struct if_flag
 #ifdef IFF_SNAP                        /* Ethernet driver outputs SNAP header. 
 */
     {"SNAP", IFF_SNAP, 0},
 #endif
+#ifdef IFF_MONITOR
+    {"MONITOR", IFF_MONITOR, 0},
+#endif
+#ifdef IFF_STATICARP
+    {"STATICARP", IFF_STATICARP, 0},
+#endif
     { NULL, 0, 0}
   };
 
@@ -423,10 +435,16 @@ static struct if_flag_char flag_char_tab[] = {
   { IFF_POINTOPOINT, 'P' },
 #endif
 #ifdef IFF_SLAVE
-  { IFF_SLAVE,       's' },
+  { IFF_SLAVE,       's' },    /* Linux */
+#endif
+#ifdef IFF_STATICARP
+  { IFF_STATICARP,   's' },    /* FreeBSD */
 #endif
 #ifdef IFF_MASTER
-  { IFF_MASTER,      'm' },
+  { IFF_MASTER,      'm' },    /* Linux */
+#endif
+#ifdef IFF_MONITOR
+  { IFF_MONITOR,     'm' },    /* FreeBSD */
 #endif
 #ifdef IFF_SIMPLEX
   { IFF_SIMPLEX,     'S' },
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 5e7265a..2c18ac8 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -157,7 +157,7 @@ struct format formats[] = {
    "Traditional UNIX interface listing.  Default for Solaris, BSD and HPUX.",
    "${format}{check-existence}"
    "${ifdisplay?}{"
-   "${name}: flags=${flags}{number}{%hx}<${flags}{string}{,}>"
+   "${name}: flags=${flags}{number}{%x}<${flags}{string}{,}>"
    "${metric?}{ metric ${metric}}"
    "${mtu?}{ mtu ${mtu}}${\\n}"
    /* Print only if hwtype emits something.  */
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index 25cc8ea..3f8347f 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -303,15 +303,16 @@ put_addr (format_data_t form, int argc, char *argv[], 
struct sockaddr *sa)
 }
 
 void
-put_flags (format_data_t form, int argc, char *argv[], short flags)
+put_flags (format_data_t form, int argc, char *argv[], int flags)
 {
-  unsigned short int f = 1;
+  unsigned int f = 1;
   const char *name;
   int first = 1;
+  unsigned int uflags = (unsigned int) flags;
 
-  while (flags && f)
+  while (uflags && f)
     {
-      if (f & flags)
+      if (f & uflags)
        {
          name = if_flagtoname (f, NULL);
          if (name)
@@ -324,13 +325,13 @@ put_flags (format_data_t form, int argc, char *argv[], 
short flags)
                    put_char (form, ' ');
                }
              put_string (form, name);
-             flags &= ~f;
+             uflags &= ~f;
              first = 0;
            }
        }
       f = f << 1;
     }
-  if (flags)
+  if (uflags)
     {
       if (!first)
        {
@@ -339,13 +340,13 @@ put_flags (format_data_t form, int argc, char *argv[], 
short flags)
          else
            put_char (form, ' ');
        }
-      put_int (form, argc - 1, &argv[1], flags);
+      put_int (form, argc - 1, &argv[1], uflags);
     }
 }
 
 void
 put_flags_short (format_data_t form, int argc _GL_UNUSED_PARAMETER,
-                char *argv[] _GL_UNUSED_PARAMETER, short flags)
+                char *argv[] _GL_UNUSED_PARAMETER, int flags)
 {
   char buf[IF_FORMAT_FLAGS_BUFSIZE];
   if_format_flags (flags, buf, sizeof buf);
@@ -482,11 +483,16 @@ fh_ifdisplay_query (format_data_t form, int argc, char 
*argv[])
 #ifdef SIOCGIFFLAGS
   int f;
   int rev;
+  unsigned int uflags = (unsigned short) form->ifr->ifr_flags;
+
+# ifdef ifr_flagshigh
+  uflags |= (unsigned short) form->ifr->ifr_flagshigh << 16;
+# endif /* ifr_flagshigh */
 
   n = !(all_option || ifs_cmdline
        || ((f = if_nameztoflag ("UP", &rev))
            && ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) == 0
-           && (f & form->ifr->ifr_flags)));
+           && (f & uflags)));
 #else
   n = 0;
 #endif
@@ -706,10 +712,15 @@ fh_brdaddr_query (format_data_t form, int argc, char 
*argv[])
 # ifdef SIOCGIFFLAGS
   int f;
   int rev;
+  unsigned int uflags = (unsigned short) form->ifr->ifr_flags;
+
+# ifdef ifr_flagshigh
+  uflags |= (unsigned short) form->ifr->ifr_flagshigh << 16;
+# endif /* ifr_flagshigh */
 
   if (0 == (f = if_nameztoflag ("BROADCAST", &rev))
       || (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
-      || ((f & form->ifr->ifr_flags) == 0))
+      || ((f & uflags) == 0))
     {
       select_arg (form, argc, argv, 1);
       return;
@@ -745,10 +756,15 @@ fh_dstaddr_query (format_data_t form, int argc, char 
*argv[])
 # ifdef SIOCGIFFLAGS
   int f;
   int rev;
+  unsigned int uflags = (unsigned short) form->ifr->ifr_flags;
+
+#  ifdef ifr_flagshigh
+  uflags |= (unsigned short) form->ifr->ifr_flagshigh << 16;
+#  endif /* ifr_flagshigh */
 
   if (0 == (f = if_nameztoflag ("POINTOPOINT", &rev))
       || (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
-      || ((f & form->ifr->ifr_flags) == 0))
+      || ((f & uflags) == 0))
     {
       select_arg (form, argc, argv, 1);
       return;
@@ -856,17 +872,23 @@ fh_flags (format_data_t form, int argc, char *argv[])
           form->ifr->ifr_name);
   else
     {
+      unsigned int uflags = (unsigned short) form->ifr->ifr_flags;
+
+# ifdef ifr_flagshigh
+      uflags |= (unsigned short) form->ifr->ifr_flagshigh << 16;
+# endif /* ifr_flagshigh */
+
       if (argc >= 1)
        {
          if (!strcmp (argv[0], "number"))
-           put_int (form, argc - 1, &argv[1], form->ifr->ifr_flags);
+           put_int (form, argc - 1, &argv[1], uflags);
          else if (!strcmp (argv[0], "short"))
-           put_flags_short (form, argc - 1, &argv[1], form->ifr->ifr_flags);
+           put_flags_short (form, argc - 1, &argv[1], uflags);
          else if (!strcmp (argv[0], "string"))
-           put_flags (form, argc - 1, &argv[1], form->ifr->ifr_flags);
+           put_flags (form, argc - 1, &argv[1], uflags);
        }
       else
-       put_flags (form, argc, argv, form->ifr->ifr_flags);
+       put_flags (form, argc, argv, uflags);
     }
 #else
   *column += printf ("(not available)");
diff --git a/ifconfig/printif.h b/ifconfig/printif.h
index e9f334d..188c068 100644
--- a/ifconfig/printif.h
+++ b/ifconfig/printif.h
@@ -67,7 +67,7 @@ void put_ulong (format_data_t form, int argc, char *argv[], 
unsigned long val);
 void select_arg (format_data_t form, int argc, char *argv[], int nr);
 void put_addr (format_data_t form, int argc, char *argv[],
               struct sockaddr *sa);
-void put_flags (format_data_t form, int argc, char *argv[], short flags);
+void put_flags (format_data_t form, int argc, char *argv[], int flags);
 
 /* Format handler can mangle form->format, so update it after calling
    here.  */

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

Summary of changes:
 ChangeLog           |   25 ++++++++++++++++++++++++
 ifconfig/changeif.c |    9 +++++++-
 ifconfig/flags.c    |   22 +++++++++++++++++++-
 ifconfig/options.c  |    2 +-
 ifconfig/printif.c  |   52 ++++++++++++++++++++++++++++++++++++--------------
 ifconfig/printif.h  |    2 +-
 6 files changed, 92 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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