[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Inetutils branch, master, updated. inetutils-1_7-26-gbd081e7
From: |
Sergey Poznyakoff |
Subject: |
[SCM] GNU Inetutils branch, master, updated. inetutils-1_7-26-gbd081e7 |
Date: |
Wed, 27 Jan 2010 19:52:00 +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 bd081e76a1cc46522a32a1fe68d4a369cebeca84 (commit)
from 4b1d4704233377254a05d2dd830c77cb3e286b79 (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=bd081e76a1cc46522a32a1fe68d4a369cebeca84
commit bd081e76a1cc46522a32a1fe68d4a369cebeca84
Author: Sergey Poznyakoff <address@hidden>
Date: Wed Jan 27 21:45:05 2010 +0200
Implement setting interface options in ifconfig: up, down, multicast,
allmulti, etc.
* ifconfig/changeif.c (set_flags): New function.
(configure_if): Set flags.
* ifconfig/flags.c (struct if_flag): New member `rev'.
(if_flagtoname) Avoid extra comparison.
(if_nametoflag): Rewrite. Take 2 additional arguments.
(if_nameztoflag): New function.
(if_format_flags): New function.
* ifconfig/flags.h (if_nametoflag): Change signature.
(if_nameztoflag): New prototype.
* ifconfig/options.c (all_option): New global.
(argp_options): Use -A as short option for --address.
Add new option -a (--all).
New options: --up, --down, --flags.
(parse_opt_set_flag, parse_opt_flag_list): New functions.
(parse_opt_set_point_to_point): New function.
(parse_opt): Handle new options.
(argp): Add help filter.
* ifconfig/options.h (struct ifconfig): New members: setflags
and clrflags.
(parse_opt_set_flag, parse_opt_flag_list)
(parse_opt_set_point_to_point): New prototypes.
* ifconfig/printif.c (fh_brdaddr_query, fh_dstaddr_query): Update
calls to if_nametoflag.
* ifconfig/system/linux.c (system_help): Update.
(system_parse_opt_rest): Allow for flags (up, down, arp, etc.)
diff --git a/ChangeLog b/ChangeLog
index 74c37c0..07a222e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2010-01-27 Sergey Poznyakoff <address@hidden>
+
+ Implement setting interface options: up, down, multicast,
+ allmulti.
+
+ * ifconfig/changeif.c (set_flags): New function.
+ (configure_if): Set flags.
+ * ifconfig/flags.c (struct if_flag): New member `rev'.
+ (if_flagtoname) Avoid extra comparison.
+ (if_nametoflag): Rewrite. Take 2 additional arguments.
+ (if_nameztoflag): New function.
+ (if_format_flags): New function.
+ * ifconfig/flags.h (if_nametoflag): Change signature.
+ (if_nameztoflag): New prototype.
+ * ifconfig/options.c (all_option): New global.
+ (argp_options): Use -A as short option for --address.
+ Add new option -a (--all).
+ New options: --up, --down, --flags.
+ (parse_opt_set_flag, parse_opt_flag_list): New functions.
+ (parse_opt_set_point_to_point): New function.
+ (parse_opt): Handle new options.
+ (argp): Add help filter.
+ * ifconfig/options.h (struct ifconfig): New members: setflags
+ and clrflags.
+ (parse_opt_set_flag, parse_opt_flag_list)
+ (parse_opt_set_point_to_point): New prototypes.
+ * ifconfig/printif.c (fh_brdaddr_query, fh_dstaddr_query): Update
+ calls to if_nametoflag.
+ * ifconfig/system/linux.c (system_help): Update.
+ (system_parse_opt_rest): Allow for flags (up, down, arp, etc.)
+
2010-01-12 Simon Josefsson <address@hidden>
* whois/whois.c (openconn) [!HAVE_GETADDRINFO]: Remove variables
@@ -1021,7 +1052,7 @@
* ping/ping_timestamp.c: Likewise.
2009-07-10 Giuseppe Scrivano <address@hidden>
- Alfred M. Szmidt <address@hidden>
+ Alfred M. Szmidt <address@hidden>
* rexecd/rexecd.c: Use EXIT_FAILURE consistently for calls to
error.
@@ -1402,7 +1433,7 @@
2008-10-14 Rakesh Pandit <address@hidden>
- * ping/ping_impl.h, ping/ping.h, ping/ping_common.h,
+ * ping/ping_impl.h, ping/ping.h, ping/ping_common.h,
ping/ping6.h (ping_stat, PEV_RESPONSE, PEV_DUPLICATE, PEV_NOECHO,
PING_INTERVAL, PING_CKTABSIZE, MAXWAIT, OPT_FLOOD, OPT_INTERVAL,
OPT_NUMERIC, OPT_QUIET, OPT_RROUTE, OPT_VERBOSE, PING_TIMING,
@@ -1485,7 +1516,7 @@
from list
* doc/Makefile.am (SUBDIRS): Remove variable.
- * doc/rfc/.cvsignore, doc/rfc/Makefile.am, doc/rfc/rfc1282.txt:
+ * doc/rfc/.cvsignore, doc/rfc/Makefile.am, doc/rfc/rfc1282.txt:
Files removed.
2008-09-26 Arash Yadegarnia <address@hidden> (tiny change)
@@ -1500,7 +1531,7 @@
2008-09-26 Alfred M. Szmidt <address@hidden>
- * doc/inetutils.texi: Refer to `COMMAND invocation' nodes for
+ * doc/inetutils.texi: Refer to `COMMAND invocation' nodes for
logger, rcp, rexecd and syslogd. Formating fixes. Mention
traceroute in the TOC.
@@ -2561,7 +2592,7 @@
2006-04-20 Sergey Poznyakoff <address@hidden>
- * Makefile.am (INCLUDES): Add -I$(top_srcdir)/libinetutils
+ * Makefile.am (INCLUDES): Add -I$(top_srcdir)/libinetutils
* ftpd/extern.h (logwtmp): Remove prototype
* ftpd/ftpd.c: Include libinetutils.h
@@ -3775,11 +3806,11 @@
Minor bugfix: LIBS and LDFLAGS were not properly
restored.
* configure.ac: Removed KERBEROS_IV and KERBEROS_V defines.
- Added check for socklen_t.
+ Added check for socklen_t.
2003-02-08 Simon Josefsson <address@hidden>
- * telnet/commands.c (tn): Don't set hostname to DNS canonicalized
+ * telnet/commands.c (tn): Don't set hostname to DNS canonicalized
value. Attackers may control DNS and fool the Kerberos
authentication code to use the wrong realm for the server, and
consequently the wrong KDC for the server, which the attackers
@@ -3909,7 +3940,7 @@
switching to the user privileges. Thanks to
Alex Muntada <address@hidden> for the idea.
Removed unneded casts to (void).
- Create a local copy of hostname, lest it be spoiled
+ Create a local copy of hostname, lest it be spoiled
by a call to localhost().
Thanks to Chris Ulherr for reporting.
@@ -3917,7 +3948,7 @@
* rexecd/rexecd.c: Change to the user's directory after
switching to the user privileges. Thanks to
- Alex Muntada <address@hidden> for the idea.
+ Alex Muntada <address@hidden> for the idea.
Removed unneded casts to (void).
2002-09-06 Sergey Poznyakoff <address@hidden>
@@ -4358,16 +4389,16 @@
2002-04-21 Alfred M. Szmidt <address@hidden>
- * ftpd/Makefile.am (inetdaemon_PROGRAMS): Use ftpd_BUILD instead of
- BUILD_FTPD.
- * ftpd/extern.h [HAVE_GETUSERSHELL_DECL]: Renamed to
HAVE_DECL_GETUSERSHELL.
- * ftpd/ftpd.c [HAVE_FCLOSE_DECL]: Renamed to HAVE_DECL_FCLOSE.
+ * ftpd/Makefile.am (inetdaemon_PROGRAMS): Use ftpd_BUILD instead of
+ BUILD_FTPD.
+ * ftpd/extern.h [HAVE_GETUSERSHELL_DECL]: Renamed to
HAVE_DECL_GETUSERSHELL.
+ * ftpd/ftpd.c [HAVE_FCLOSE_DECL]: Renamed to HAVE_DECL_FCLOSE.
2002-04-21 Alfred M. Szmidt <address@hidden>
- * ftp/Makefile.am (bin_PROGRAMS): Use ftp_BUILD instead of BUILD_FTP.
- * ftp/ftp.c [HAVE_FCLOSE_DECL]: Renamed to HAVE_DECL_FCLOSE.
- [HAVE_PCLOSE_DECL]: Renamed to HAVE_DECL_PCLOSE.
+ * ftp/Makefile.am (bin_PROGRAMS): Use ftp_BUILD instead of BUILD_FTP.
+ * ftp/ftp.c [HAVE_FCLOSE_DECL]: Renamed to HAVE_DECL_FCLOSE.
+ [HAVE_PCLOSE_DECL]: Renamed to HAVE_DECL_PCLOSE.
2002-04-21 Alfred M. Szmidt <address@hidden>
@@ -4439,7 +4470,7 @@
* telnetd/ext.h: Removed.
* telnetd/global.c: Removed.
* telnetd/authenc.c: Removed.
- * telnetd/sys_term.c: Removed
+ * telnetd/sys_term.c: Removed
* telnetd/term.c: (new) Terminal-specific functions.
* telnetd/Makefile.am: Modified.
* telnetd/telnetd.c: Rewritten.
@@ -4493,7 +4524,7 @@
* telnetd/Makefile.am: Added pty.c
* telnetd/ext.h: Changed definition of line.
* telnetd/sys_term.c: Removed unneeded functions. Some of them
- are re-implemented in pty.c
+ are re-implemented in pty.c
* telnetd/telnetd.c (doit, telnet, readstream): Reorganized.
2002-03-14 Sergey Poznyakoff <address@hidden>
@@ -4644,13 +4675,13 @@
* autogen.sh: Don't point autoheader to headers/
- * headers/acconfig.h: Move to ...
+ * headers/acconfig.h: Move to ...
* acconfig.h: Here
* Makefile.am: Require Automake 1.5. Add doc and doc/rfc to
build tree. Don't tell autoheader to look in headers/
- I moved config.h to the top_builddir to overcome a bug in
+ I moved config.h to the top_builddir to overcome a bug in
autoconf that requires the config.h to be in the same
directory as aclocal.m4
@@ -4681,7 +4712,7 @@
2001-11-22 Sergey Poznyakoff
* rlogin/rlogin.c: Fixed syntax error: sizeof int. Should be:
- sizeof(int).
+ sizeof(int).
2001-11-22 Sergey Poznyakoff
@@ -5195,7 +5226,7 @@
2001-08-11 Sergey Poznyakoff <address@hidden>
- * icmp.h: Fixed coding style to comply with GNU.
+ * icmp.h: Fixed coding style to comply with GNU.
* libicmp/icmp_address.c: Likewise.
* libicmp/icmp_cksum.c: Likewise.
* libicmp/icmp_echo.c: Likewise.
@@ -5388,7 +5419,7 @@
Patches by Alain:
* ping/ping_address.c, ping/ping_echo.c, ping/ping_router.c,
- ping/ping_timestamp.c: <signal.h> -> <sys/signal.h>
+ ping/ping_timestamp.c: <signal.h> -> <sys/signal.h>
2001-06-20 Sergey Poznyakoff <address@hidden>
@@ -5497,12 +5528,12 @@
2001-06-05 Sergey Poznyakoff <address@hidden>
- * ftpd/ftpd.c: MAP_FAILED is not defined on some systems
+ * ftpd/ftpd.c: MAP_FAILED is not defined on some systems
(e.g. Solaris, SunOS)
- * headers/paths.h: Added missing _PATH_LOGCONF, _PATH_LOGPID,
- _PATH_LOG
- * libls/print.c: Provided defaults for major() and minor() macros
- for systems lacking them.
+ * headers/paths.h: Added missing _PATH_LOGCONF, _PATH_LOGPID,
+ _PATH_LOG
+ * libls/print.c: Provided defaults for major() and minor() macros
+ for systems lacking them.
2001-06-04 Alain Magloire
@@ -7099,7 +7130,7 @@ AC_REPLACE_FUNC (setproctitle).
* ftp/ruserpass.c: MACH was define on Hurd. We protect
the defines before using them, MACH was change to MACHINE.
Noted by the Hurd people(Bayley, Marcus)
- * cmds.c : use xgetcwd().
+ * cmds.c : use xgetcwd().
1999-05-19 Alain Magloire
@@ -7402,7 +7433,7 @@ Mon May 20 13:29:32 MET DST 1996: Miquel van Smoorenburg
<address@hidden>
Added continuation line support.
* syslogd/syslogd.c (init): Add support for continuated lines
- (implemented by Miquel van Smoorenburg <address@hidden>).
+ (implemented by Miquel van Smoorenburg <address@hidden>).
* syslogd/syslog.conf.5: Mention continuated line feature.
diff --git a/ifconfig/changeif.c b/ifconfig/changeif.c
index 9848ab7..4f3bfae 100644
--- a/ifconfig/changeif.c
+++ b/ifconfig/changeif.c
@@ -189,6 +189,31 @@ set_metric (int sfd, struct ifreq *ifr, int metric)
}
int
+set_flags (int sfd, struct ifreq *ifr, int setflags, int clrflags)
+{
+#if !defined (SIOCGIFFLAGS) || !defined (SIOCSIFFLAGS)
+ error (0, 0,
+ "don't know how to set the interface flags on this system");
+ return -1;
+#else
+ struct ifreq tifr = *ifr;
+
+ if (ioctl (sfd, SIOCGIFFLAGS, &tifr) < 0)
+ {
+ error (0, errno, "SIOCGIFFLAGS failed");
+ return -1;
+ }
+ ifr->ifr_flags = (tifr.ifr_flags | setflags) & ~clrflags;
+ if (ioctl (sfd, SIOCSIFFLAGS, ifr) < 0)
+ {
+ error (0, errno, "SIOCSIFFLAGS failed");
+ return -1;
+ }
+ return 0;
+#endif
+}
+
+int
configure_if (int sfd, struct ifconfig *ifp)
{
int err = 0;
@@ -212,6 +237,8 @@ configure_if (int sfd, struct ifconfig *ifp)
err = set_metric (sfd, &ifr, ifp->metric);
if (!err && ifp->valid & IF_VALID_SYSTEM)
err = system_configure (sfd, &ifr, ifp->system);
+ if (!err && (ifp->setflags || ifp->clrflags))
+ err = set_flags (sfd, &ifr, ifp->setflags, ifp->clrflags);
if (!err && ifp->valid & IF_VALID_FORMAT)
print_interface (sfd, ifp->name, &ifr, ifp->format);
return err;
diff --git a/ifconfig/flags.c b/ifconfig/flags.c
index 78870bf..c948cea 100644
--- a/ifconfig/flags.c
+++ b/ifconfig/flags.c
@@ -34,7 +34,9 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
+#include <stdlib.h>
#include "ifconfig.h"
+#include "xalloc.h"
/* Conversion table for interface flag names.
The mask must be a power of 2. */
@@ -42,6 +44,7 @@ struct if_flag
{
const char *name;
int mask;
+ int rev;
} if_flags[] =
{
/* Available on all systems which derive the network interface from
@@ -68,6 +71,7 @@ struct if_flag
#endif
#ifdef IFF_NOARP /* No address resolution protocol. */
{"NOARP", IFF_NOARP},
+ {"ARP", IFF_NOARP, 1},
#endif
#ifdef IFF_PROMISC /* Receive all packets. */
{"PROMISC", IFF_PROMISC},
@@ -83,6 +87,7 @@ struct if_flag
#ifdef IFF_NOTRAILERS /* Avoid use of trailers. */
/* Obsoleted on FreeBSD systems. */
{"NOTRAILERS", IFF_NOTRAILERS},
+ {"TRAILERS", IFF_NOTRAILERS, 1},
#endif
/* Available on GNU and Linux systems. */
#ifdef IFF_MASTER /* Master of a load balancer. */
@@ -148,6 +153,7 @@ struct if_flag
/* Available on HP-UX 10.20 systems. */
#ifdef IFF_NOTRAILERS /* Avoid use of trailers. */
{"NOTRAILERS", IFF_NOTRAILERS},
+ {"TRAILERS", IFF_NOTRAILERS, 1},
#endif
#ifdef IFF_LOCALSUBNETS /* Subnets of this net are local. */
{"LOCALSUBNETS", IFF_LOCALSUBNETS},
@@ -157,12 +163,14 @@ struct if_flag
#endif
#ifdef IFF_NOACC /* No data access on outbound. */
{"NOACC", IFF_NOACC},
+ {"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},
+ {"SR8025", IFF_NOSR8025, 1},
#endif
#ifdef IFF_CKO_ETC /* Interface supports trailer checksum. */
{"CKO_ETC", IFF_CKO_ETC},
@@ -191,6 +199,7 @@ struct if_flag
#endif
#ifdef IFF_NOCHECKSUM /* No checksums needed (reliable media). */
{"NOCHECKSUM", IFF_NOCHECKSUM},
+ {"CHECKSUM", IFF_NOCHECKSUM, 1},
#endif
#ifdef IFF_MULTINET /* Multiple networks on interface. */
{"MULTINET", IFF_MULTINET},
@@ -217,27 +226,100 @@ struct if_flag
#endif
};
+static int
+cmpname (const void *a, const void *b)
+{
+ return strcmp (*(const char**)a, *(const char**)b);
+}
+
+char *
+if_format_flags (const char *prefix)
+{
+ size_t len = 0;
+ struct if_flag *fp;
+ char **fnames;
+ size_t i, fcount;
+ char *str, *p;
+
+ for (fp = if_flags, len = 0, fcount = 0; fp->name; fp++)
+ if (!fp->rev)
+ {
+ fcount++;
+ len += strlen (fp->name) + 1;
+ }
+
+ fcount = sizeof (if_flags) / sizeof (if_flags[0]) - 1;
+ fnames = xmalloc (fcount * sizeof (fnames[0]) + len);
+ p = (char*)(fnames + fcount);
+
+ for (fp = if_flags, i = 0; fp->name; fp++)
+ if (!fp->rev)
+ {
+ const char *q;
+
+ fnames[i++] = p;
+ q = fp->name;
+ if (strncmp (q, "NO", 2) == 0)
+ q += 2;
+ for (; *q; q++)
+ *p++ = tolower (*q);
+ *p++ = 0;
+ }
+ fcount = i;
+ qsort (fnames, fcount, sizeof (fnames[0]), cmpname);
+
+ len += 2 * fcount;
+
+ if (prefix)
+ len += strlen (prefix);
+
+ str = xmalloc (len + 1);
+ p = str;
+ if (prefix)
+ {
+ strcpy (p, prefix);
+ p += strlen (prefix);
+ }
+
+ for (i = 0; i < fcount; i++)
+ {
+ if (i && strcmp (fnames[i - 1], fnames[i]) == 0)
+ continue;
+ strcpy (p, fnames[i]);
+ p += strlen (fnames[i]);
+ if (++i < fcount)
+ {
+ *p++ = ',';
+ *p++ = ' ';
+ }
+ else
+ break;
+ }
+ *p = 0;
+ free (fnames);
+ return str;
+}
+
/* Return the name corresponding to the interface flag FLAG.
If FLAG is unknown, return NULL.
- AVOID contains a ':' surrounded and seperated list of flag names
+ AVOID contains a ':' surrounded and separated list of flag names
that should be avoided if alternative names with the same flag value
exists. The first unavoided match is returned, or the first avoided
match if no better is available. */
const char *
if_flagtoname (int flag, const char *avoid)
{
- struct if_flag *fp = if_flags;
+ struct if_flag *fp;
const char *first_match = NULL;
char *start;
- while (fp->name)
+ for (fp = if_flags; ; fp++)
{
- if (flag == fp->mask)
+ if (!fp->name)
+ return NULL;
+ if (flag == fp->mask && !fp->rev)
break;
- fp++;
}
- if (!fp->name)
- return NULL;
first_match = fp->name;
@@ -259,17 +341,40 @@ if_flagtoname (int flag, const char *avoid)
return first_match;
}
-/* Return the flag mask corresponding to flag name NAME. If no flag
- with this name is found, return 0. */
int
-if_nametoflag (const char *name)
+if_nametoflag (const char *name, size_t len, int *prev)
{
- struct if_flag *fp = if_flags;
+ struct if_flag *fp;
+ int rev = 0;
+
+ if (len > 1 && name[0] == '-')
+ {
+ name++;
+ len--;
+ rev = 1;
+ }
+ else if (len > 2 && strncasecmp (name, "NO", 2) == 0)
+ {
+ name += 2;
+ len -= 2;
+ rev = 1;
+ }
- while (fp->name && strcasecmp (name, fp->name))
- fp++;
+ for (fp = if_flags; fp->name; fp++)
+ {
+ if (strncasecmp (fp->name, name, len) == 0)
+ {
+ *prev = fp->rev ^ rev;
+ return fp->mask;
+ }
+ }
+ return 0;
+}
- return fp->mask;
+int
+if_nameztoflag (const char *name, int *prev)
+{
+ return if_nametoflag (name, strlen (name), prev);
}
/* Print the flags in FLAGS, using AVOID as in if_flagtoname, and
diff --git a/ifconfig/flags.h b/ifconfig/flags.h
index 516efae..713cf1c 100644
--- a/ifconfig/flags.h
+++ b/ifconfig/flags.h
@@ -44,11 +44,14 @@ const char *if_flagtoname (int flag, const char *avoid);
/* Return the flag mask corresponding to flag name NAME. If no flag
with this name is found, return 0. */
-int if_nametoflag (const char *name);
+int if_nametoflag (const char *name, size_t len, int *prev);
+int if_nameztoflag (const char *name, int *prev);
/* Print the flags in FLAGS, using AVOID as in if_flagtoname, and
SEPERATOR between individual flags. Returns the number of
characters printed. */
int print_if_flags (int flags, const char *avoid, char seperator);
+char *if_format_flags (const char *prefix);
+
#endif
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 0ee1921..6064fe7 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -146,33 +146,45 @@ struct format formats[] = {
/* Default format. */
const char *default_format;
+/* Display all interfaces, even if down */
+int all_option;
enum {
METRIC_OPTION = 256,
- FORMAT_OPTION
+ FORMAT_OPTION,
+ UP_OPTION,
+ DOWN_OPTION,
};
static struct argp_option argp_options[] = {
{ "verbose", 'v', NULL, 0,
"output information when configuring interface" },
+ { "all", 'a', NULL, 0,
+ "display all available interfaces" },
{ "interface", 'i', "NAME", 0,
"configure network interface NAME" },
- { "address", 'a', "ADDR", 0,
+ { "address", 'A', "ADDR", 0,
"set interface address to ADDR" },
{ "netmask", 'm', "MASK", 0,
"set netmask to MASK" },
{ "dstaddr", 'd', "ADDR", 0,
"set destination (peer) address to ADDR" },
- { "peer", 'p', NULL, OPTION_ALIAS },
+ { "peer", 'p', "ADDR", OPTION_ALIAS },
{ "broadcast", 'B', "ADDR", 0,
"set broadcast address to ADDR" },
{ "brdaddr", 'b', NULL, OPTION_ALIAS, }, /* FIXME: Do we really need it? */
{ "mtu", 'M', "N", 0,
- "et mtu of interface to N" },
+ "set mtu of interface to N" },
{ "metric", METRIC_OPTION, "N", 0,
"set metric of interface to N" },
{ "format", FORMAT_OPTION, "FORMAT", 0,
"select output format (or set back to default)" },
+ { "up", UP_OPTION, NULL, 0,
+ "activate the interface (default if address is given)" },
+ { "down", DOWN_OPTION, NULL, 0,
+ "shut the interface down" },
+ { "flags", 'F', "FLAG[,FLAG...]", 0,
+ "set interface flags" },
{ NULL }
};
@@ -182,7 +194,7 @@ const char *program_authors[] =
"Marcus Brinkmann",
NULL
};
-
+
struct ifconfig *
parse_opt_new_ifs (char *name)
{
@@ -203,10 +215,10 @@ parse_opt_set_##field (struct ifconfig *ifp, char *addr)
\
{ \
if (!ifp) \
error (EXIT_FAILURE, 0, \
- "no interface specified for %s `%s'", #fname, addr); \
+ "no interface specified for %s `%s'", #fname, addr); \
if (ifp->valid & IF_VALID_##fvalid) \
error (EXIT_FAILURE, 0, \
- "only one %s allowed for interface `%s'", \
+ "only one %s allowed for interface `%s'", \
#fname, ifp->name); \
ifp->field = addr; \
ifp->valid |= IF_VALID_##fvalid; \
@@ -216,6 +228,7 @@ PARSE_OPT_SET_ADDR (address, address, ADDR)
PARSE_OPT_SET_ADDR (netmask, netmask, NETMASK)
PARSE_OPT_SET_ADDR (dstaddr, destination / peer address, DSTADDR)
PARSE_OPT_SET_ADDR (brdaddr, broadcast address, BRDADDR)
+
#define PARSE_OPT_SET_INT(field, fname, fvalid) \
void \
parse_opt_set_##field (struct ifconfig *ifp, char *arg) \
@@ -223,17 +236,17 @@ parse_opt_set_##field (struct ifconfig *ifp, char *arg)
\
char *end; \
if (!ifp) \
error (EXIT_FAILURE, 0, \
- "no interface specified for %s `%s'\n", \
- #fname, arg); \
+ "no interface specified for %s `%s'\n", \
+ #fname, arg); \
if (ifp->valid & IF_VALID_##fvalid) \
error (EXIT_FAILURE, 0, \
- "only one %s allowed for interface `%s'", \
- #fname, ifp->name); \
+ "only one %s allowed for interface `%s'", \
+ #fname, ifp->name); \
ifp->field = strtol (arg, &end, 0); \
if (*arg == '\0' || *end != '\0') \
error (EXIT_FAILURE, 0, \
- "mtu value `%s' for interface `%s' is not a number", \
- arg, ifp->name); \
+ "mtu value `%s' for interface `%s' is not a number", \
+ arg, ifp->name); \
ifp->valid |= IF_VALID_##fvalid; \
}
PARSE_OPT_SET_INT (mtu, mtu value, MTU)
@@ -242,18 +255,58 @@ void parse_opt_set_af (struct ifconfig *ifp, char *af)
{
if (!ifp)
error (EXIT_FAILURE, 0,
- "no interface specified for address family `%s'", af);
+ "no interface specified for address family `%s'", af);
if (!strcasecmp (af, "inet"))
ifp->af = AF_INET;
else
error (EXIT_FAILURE, 0,
- "unknown address family `%s' for interface `%s': is not a number",
- af, ifp->name);
+ "unknown address family `%s' for interface `%s': is not a number",
+ af, ifp->name);
ifp->valid |= IF_VALID_AF;
}
void
+parse_opt_set_flag (struct ifconfig *ifp, int flag, int rev)
+{
+ if (rev)
+ ifp->clrflags |= flag;
+ else
+ ifp->setflags |= flag;
+}
+
+void
+parse_opt_flag_list (struct ifconfig *ifp, const char *name)
+{
+ while (*name)
+ {
+ int mask, rev;
+ char *p = strchr (name, ',');
+ size_t len;
+
+ if (p)
+ len = p - name;
+ else
+ len = strlen (name);
+
+ if ((mask = if_nametoflag (name, len, &rev)) == 0)
+ error (EXIT_FAILURE, 0, "unknown flag %*.*s", len, len, name);
+ parse_opt_set_flag (ifp, mask, rev);
+
+ name += len;
+ if (p)
+ name++;
+ }
+}
+
+void
+parse_opt_set_point_to_point (struct ifconfig *ifp, char *addr)
+{
+ parse_opt_set_dstaddr (ifp, addr);
+ parse_opt_set_flag (ifp, IFF_POINTOPOINT, 0);
+}
+
+void
parse_opt_set_default_format (const char *new_format)
{
struct format *frm = formats;
@@ -293,20 +346,24 @@ static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
struct ifconfig *ifp = *(struct ifconfig **)state->input;
-
+
switch (key)
{
case ARGP_KEY_INIT:
state->child_inputs[0] = state->input;
break;
-
+
case 'i': /* Interface name. */
parse_opt_finalize (ifp);
ifp = parse_opt_new_ifs (arg);
*(struct ifconfig **) state->input = ifp;
break;
- case 'a': /* Interface address. */
+ case 'a':
+ all_option = 1;
+ break;
+
+ case 'A': /* Interface address. */
parse_opt_set_address (ifp, arg);
break;
@@ -316,7 +373,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'd': /* Interface dstaddr. */
case 'p':
- parse_opt_set_dstaddr (ifp, arg);
+ parse_opt_set_point_to_point (ifp, arg);
break;
case 'b': /* Interface broadcast address. */
@@ -324,10 +381,18 @@ parse_opt (int key, char *arg, struct argp_state *state)
parse_opt_set_brdaddr (ifp, arg);
break;
+ case 'F':
+ parse_opt_flag_list (ifp, arg);
+ break;
+
case 'M': /* Interface MTU. */
parse_opt_set_mtu (ifp, arg);
break;
+ case 'v':
+ verbose++;
+ break;
+
case METRIC_OPTION: /* Interface metric. */
parse_opt_set_metric (ifp, arg);
break;
@@ -336,6 +401,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
parse_opt_set_default_format (arg);
break;
+ case UP_OPTION:
+ parse_opt_set_flag (ifp, IFF_UP | IFF_RUNNING, 0);
+ break;
+
+ case DOWN_OPTION:
+ parse_opt_set_flag (ifp, IFF_UP, 1);
+ break;
+
default:
return ARGP_ERR_UNKNOWN;
}
@@ -343,6 +416,23 @@ parse_opt (int key, char *arg, struct argp_state *state)
return 0;
}
+static char *
+default_help_filter (int key, const char *text, void *input)
+{
+ char *s;
+
+ switch (key)
+ {
+ default:
+ s = (char*) text;
+ break;
+
+ case ARGP_KEY_HELP_EXTRA:
+ s = if_format_flags ("Known flags are: ");
+ }
+ return s;
+}
+
static struct argp_child argp_children[2];
static struct argp argp =
{
@@ -350,6 +440,8 @@ static struct argp argp =
parse_opt,
NULL,
doc,
+ NULL,
+ default_help_filter
};
@@ -388,7 +480,7 @@ parse_cmdline (int argc, char *argv[])
ifs = realloc (ifs, ++nifs * sizeof (struct ifconfig));
if (!ifs)
error (EXIT_FAILURE, errno,
- "can't get memory for interface configuration");
+ "can't get memory for interface configuration");
ifp = &ifs[nifs - 1];
*ifp = ifconfig_initializer;
ifp->name = ifnxp->if_name;
@@ -397,7 +489,7 @@ parse_cmdline (int argc, char *argv[])
ifnxp++;
}
/* XXX: We never do if_freenameindex (ifnx), because we are
- keeping the names for later instead using strdup
- (if->if_name) here. */
+ keeping the names for later instead using strdup
+ (if->if_name) here. */
}
}
diff --git a/ifconfig/options.h b/ifconfig/options.h
index e578666..43b5d33 100644
--- a/ifconfig/options.h
+++ b/ifconfig/options.h
@@ -32,9 +32,9 @@ struct ifconfig
{
char *name;
int valid;
-# define IF_VALID_SYSTEM 0x001
+# define IF_VALID_SYSTEM 0x001
struct system_ifconfig *system;
-# define IF_VALID_FORMAT 0x002
+# define IF_VALID_FORMAT 0x002
const char *format;
# define IF_VALID_AF 0x004
sa_family_t af;
@@ -48,8 +48,10 @@ struct ifconfig
char *brdaddr;
# define IF_VALID_MTU 0x080
int mtu;
-# define IF_VALID_METRIC 0x100
+# define IF_VALID_METRIC 0x100
int metric;
+ int setflags;
+ int clrflags;
};
struct format
@@ -75,6 +77,10 @@ void parse_opt_set_netmask (struct ifconfig *ifp, char
*addr);
void parse_opt_set_mtu (struct ifconfig *ifp, char *addr);
void parse_opt_set_metric (struct ifconfig *ifp, char *addr);
void parse_opt_set_default_format (const char *format);
+void parse_opt_set_flag (struct ifconfig *ifp, int flag, int rev);
+void parse_opt_flag_list (struct ifconfig *ifp, const char *name);
+void parse_opt_set_point_to_point (struct ifconfig *ifp, char *addr);
+
void parse_opt_finalize (struct ifconfig *ifp);
void parse_cmdline (int argc, char *argv[]);
diff --git a/ifconfig/printif.c b/ifconfig/printif.c
index 784185a..4db2792 100644
--- a/ifconfig/printif.c
+++ b/ifconfig/printif.c
@@ -215,7 +215,7 @@ put_ulong (format_data_t form, int argc, char *argv[],
unsigned long value)
if (*p == 'l')
p++;
-
+
switch (*p)
{
default:
@@ -519,7 +519,7 @@ fh_index (format_data_t form, int argc, char *argv[])
if (indx == 0)
error (EXIT_FAILURE, errno,
- "No index number found for interface `%s'",
+ "No index number found for interface `%s'",
form->name);
*column += printf ("%i", indx);
had_output = 1;
@@ -542,7 +542,7 @@ fh_addr (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFADDR
if (ioctl (form->sfd, SIOCGIFADDR, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFADDR failed for interface `%s'",
+ "SIOCGIFADDR failed for interface `%s'",
form->ifr->ifr_name);
else
put_addr (form, argc, argv, &form->ifr->ifr_addr);
@@ -569,7 +569,7 @@ fh_netmask (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFNETMASK
if (ioctl (form->sfd, SIOCGIFNETMASK, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFNETMASK failed for interface `%s'",
+ "SIOCGIFNETMASK failed for interface `%s'",
form->ifr->ifr_name);
else
put_addr (form, argc, argv, &form->ifr->ifr_netmask);
@@ -585,8 +585,9 @@ fh_brdaddr_query (format_data_t form, int argc, char
*argv[])
#ifdef SIOCGIFBRDADDR
# ifdef SIOCGIFFLAGS
int f;
+ int rev;
- if (0 == (f = if_nametoflag ("BROADCAST"))
+ if (0 == (f = if_nameztoflag ("BROADCAST", &rev))
|| (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
|| ((f & form->ifr->ifr_flags) == 0))
{
@@ -607,8 +608,8 @@ fh_brdaddr (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFBRDADDR
if (ioctl (form->sfd, SIOCGIFBRDADDR, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFBRDADDR failed for interface `%s'",
- form->ifr->ifr_name);
+ "SIOCGIFBRDADDR failed for interface `%s'",
+ form->ifr->ifr_name);
else
put_addr (form, argc, argv, &form->ifr->ifr_broadaddr);
#else
@@ -623,8 +624,9 @@ fh_dstaddr_query (format_data_t form, int argc, char
*argv[])
#ifdef SIOCGIFDSTADDR
# ifdef SIOCGIFFLAGS
int f;
+ int rev;
- if (0 == (f = if_nametoflag ("POINTOPOINT"))
+ if (0 == (f = if_nameztoflag ("POINTOPOINT", &rev))
|| (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
|| ((f & form->ifr->ifr_flags) == 0))
{
@@ -645,7 +647,7 @@ fh_dstaddr (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFDSTADDR
if (ioctl (form->sfd, SIOCGIFDSTADDR, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFDSTADDR failed for interface `%s'",
+ "SIOCGIFDSTADDR failed for interface `%s'",
form->ifr->ifr_name);
else
put_addr (form, argc, argv, &form->ifr->ifr_dstaddr);
@@ -672,7 +674,7 @@ fh_mtu (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFMTU
if (ioctl (form->sfd, SIOCGIFMTU, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFMTU failed for interface `%s'",
+ "SIOCGIFMTU failed for interface `%s'",
form->ifr->ifr_name);
else
put_int (form, argc, argv, form->ifr->ifr_mtu);
@@ -699,7 +701,7 @@ 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'",
+ "SIOCGIFMETRIC failed for interface `%s'",
form->ifr->ifr_name);
else
put_int (form, argc, argv, form->ifr->ifr_metric);
@@ -726,7 +728,7 @@ fh_flags (format_data_t form, int argc, char *argv[])
#ifdef SIOCGIFFLAGS
if (ioctl (form->sfd, SIOCGIFFLAGS, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFFLAGS failed for interface `%s'",
+ "SIOCGIFFLAGS failed for interface `%s'",
form->ifr->ifr_name);
else
{
@@ -786,7 +788,7 @@ fh_baseaddr_query (format_data_t form, int argc, char
*argv[])
void
fh_baseaddr (format_data_t form, int argc, char *argv[])
{
- if (form->ifr->ifr_map.base_addr >= 0x100)
+ if (form->ifr->ifr_map.base_addr >= 0x100)
put_int (form, argc, argv, form->ifr->ifr_map.base_addr);
else
put_string (form, "(not available)");
@@ -804,7 +806,7 @@ fh_memstart_query (format_data_t form, int argc, char
*argv[])
void
fh_memstart (format_data_t form, int argc, char *argv[])
{
- if (form->ifr->ifr_map.mem_start)
+ if (form->ifr->ifr_map.mem_start)
put_ulong (form, argc, argv, form->ifr->ifr_map.mem_start);
else
put_string (form, "(not available)");
@@ -822,7 +824,7 @@ fh_memend_query (format_data_t form, int argc, char *argv[])
void
fh_memend (format_data_t form, int argc, char *argv[])
{
- if (form->ifr->ifr_map.mem_end)
+ if (form->ifr->ifr_map.mem_end)
put_ulong (form, argc, argv, form->ifr->ifr_map.mem_end);
else
put_string (form, "(not available)");
@@ -840,7 +842,7 @@ fh_dma_query (format_data_t form, int argc, char *argv[])
void
fh_dma (format_data_t form, int argc, char *argv[])
{
- if (form->ifr->ifr_map.dma)
+ if (form->ifr->ifr_map.dma)
put_int (form, argc, argv, form->ifr->ifr_map.dma);
else
put_string (form, "(not available)");
@@ -868,8 +870,8 @@ print_interfaceX (format_data_t form, int quiet)
break;
/* Look at next character. If it is a '$' or '}', print that
- and skip the '$'. If it is something else than '{', print
- both. Otherwise enter substitution mode. */
+ and skip the '$'. If it is something else than '{', print
+ both. Otherwise enter substitution mode. */
switch (*(++p))
{
default:
diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index 4af9186..8a72903 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -289,7 +289,7 @@ struct pnd_stats
unsigned long rx_dropped; /* input packets dropped */
unsigned long tx_dropped; /* transmit packets dropped */
unsigned long rx_multicast; /* multicast packets received */
- unsigned long rx_compressed; /* compressed packets received */
+ unsigned long rx_compressed; /* compressed packets received */
unsigned long tx_compressed; /* compressed packets transmitted */
unsigned long collisions;
@@ -428,7 +428,7 @@ pnd_read ()
struct pnd_stats *stats = xzalloc (sizeof (*stats));;
char *p = buf, *q;
size_t len;
-
+
while (*p
&& isascii (*(unsigned char*) p) && isspace (*(unsigned char*) p))
p++;
@@ -487,7 +487,7 @@ system_fh_ifstat_query (format_data_t form, int argc, char
*argv[])
{
select_arg (form, argc, argv,
pnd_stats_locate (form->ifr->ifr_name) ? 0 : 1);
-}
+}
#define _IU_DECLARE(fld) \
void \
@@ -496,7 +496,7 @@ _IU_CAT2 (system_fh_,fld) (format_data_t form, int argc,
char *argv[]) \
struct pnd_stats *stats = pnd_stats_locate (form->ifr->ifr_name); \
if (!stats) \
put_string (form, "(" #fld " unknown)"); \
- else
\
+ else \
put_ulong (form, argc, argv, stats->fld); \
}
@@ -546,7 +546,7 @@ system_fh_hwaddr (format_data_t form, int argc, char
*argv[])
#ifdef SIOCGIFHWADDR
if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFHWADDR failed for interface `%s'",
+ "SIOCGIFHWADDR failed for interface `%s'",
form->ifr->ifr_name);
else
{
@@ -555,7 +555,7 @@ system_fh_hwaddr (format_data_t form, int argc, char
*argv[])
arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
if (arp && arp->print_hwaddr)
arp->print_hwaddr (form,
- (unsigned char *) form->ifr->ifr_hwaddr.sa_data);
+ (unsigned char *) form->ifr->ifr_hwaddr.sa_data);
else
put_string (form, "(hwaddr unknown)");
}
@@ -582,7 +582,7 @@ system_fh_hwtype (format_data_t form, int argc, char
*argv[])
#ifdef SIOCGIFHWADDR
if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFHWADDR failed for interface `%s'",
+ "SIOCGIFHWADDR failed for interface `%s'",
form->ifr->ifr_name);
else
{
@@ -617,7 +617,7 @@ system_fh_txqlen (format_data_t form, int argc, char
*argv[])
#ifdef SIOCGIFTXQLEN
if (ioctl (form->sfd, SIOCGIFTXQLEN, form->ifr) < 0)
error (EXIT_FAILURE, errno,
- "SIOCGIFTXQLEN failed for interface `%s'",
+ "SIOCGIFTXQLEN failed for interface `%s'",
form->ifr->ifr_name);
else
put_int (form, argc, argv, form->ifr->ifr_qlen);
@@ -633,7 +633,7 @@ system_fh_txqlen (format_data_t form, int argc, char
*argv[])
const char *system_help = "\
NAME [ADDR] [broadcast BRDADDR]\
[pointopoint|dstaddr DSTADDR] [netmask MASK]\
- [metric N] [mtu N] [txqueuelen N]";
+ [metric N] [mtu N] [txqueuelen N] [up|down] [FLAGS]";
void
system_parse_opt_set_txqlen (struct ifconfig *ifp, char *arg)
@@ -642,7 +642,7 @@ system_parse_opt_set_txqlen (struct ifconfig *ifp, char
*arg)
if (!ifp)
error (EXIT_FAILURE, 0,
- "no interface specified for txqlen `%s'", arg);
+ "no interface specified for txqlen `%s'", arg);
if (!(ifp->valid & IF_VALID_SYSTEM))
{
@@ -655,13 +655,13 @@ system_parse_opt_set_txqlen (struct ifconfig *ifp, char
*arg)
}
if (ifp->system->valid & IF_VALID_TXQLEN)
error (EXIT_FAILURE, 0,
- "only one txqlen allowed for interface `%s'",
+ "only one txqlen allowed for interface `%s'",
ifp->name);
ifp->system->txqlen = strtol (arg, &end, 0);
if (*arg == '\0' || *end != '\0')
error (EXIT_FAILURE, 0,
- "txqlen value `%s' for interface `%s' is not a number",
- arg, ifp->name);
+ "txqlen value `%s' for interface `%s' is not a number",
+ arg, ifp->name);
ifp->system->valid |= IF_VALID_TXQLEN;
}
@@ -727,8 +727,9 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc,
char *argv[])
EXPECT_NETMASK,
EXPECT_MTU,
EXPECT_METRIC,
- EXPECT_TXQLEN
+ EXPECT_TXQLEN,
} expect = EXPECT_INET;
+ int mask, rev;
*ifp = parse_opt_new_ifs (argv[0]);
@@ -741,7 +742,7 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc,
char *argv[])
break;
case EXPECT_DSTADDR:
- parse_opt_set_dstaddr (*ifp, argv[i]);
+ parse_opt_set_point_to_point (*ifp, argv[i]);
break;
case EXPECT_NETMASK:
@@ -765,7 +766,7 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc,
char *argv[])
if (!strcmp (argv[i], "inet"))
continue;
break;
-
+
case EXPECT_NOTHING:
break;
}
@@ -785,6 +786,12 @@ system_parse_opt_rest (struct ifconfig **ifp, int argc,
char *argv[])
expect = EXPECT_MTU;
else if (!strcmp (argv[i], "txqueuelen"))
expect = EXPECT_TXQLEN;
+ 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 if ((mask = if_nameztoflag (argv[i], &rev)) != 0)
+ parse_opt_set_flag (*ifp, mask, rev);
else
parse_opt_set_address (*ifp, argv[i]);
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 91 +++++++++++++++++++++----------
ifconfig/changeif.c | 27 +++++++++
ifconfig/flags.c | 133 ++++++++++++++++++++++++++++++++++++++++-----
ifconfig/flags.h | 5 ++-
ifconfig/options.c | 138 +++++++++++++++++++++++++++++++++++++++--------
ifconfig/options.h | 12 +++-
ifconfig/printif.c | 38 +++++++------
ifconfig/system/linux.c | 39 ++++++++------
8 files changed, 378 insertions(+), 105 deletions(-)
hooks/post-receive
--
GNU Inetutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Inetutils branch, master, updated. inetutils-1_7-26-gbd081e7,
Sergey Poznyakoff <=