Home | History | Annotate | only in /src/sbin/ifconfig
History log of /src/sbin/ifconfig
RevisionDateAuthorComments
 1.62 04-Apr-2025  rin ifconfig/Makefile: Makefile.inc -> Makefile.common in comment, NFC

I forgot to update this comment when I renamed Makefile.inc to .common.
 1.61 10-Oct-2017  christos branches: 1.61.16;
user librumpres
 1.60 08-Feb-2017  rin Cosmetic changes. No functional changes.
 1.59 08-Feb-2017  rin Factor out a common part in Makefile's of ifconfig and x_ifconfig.
 1.58 08-Feb-2017  rin Rename sbin/ifconfig/Makefile.inc to Makefile.common; the former can
potentially conflict with bsd.subdir.mk.
 1.57 08-Feb-2017  rin Remove ifconfig hack on m68000. I've confirmed that the problem has already
gone with TME.
 1.56 19-May-2015  ozaki-r branches: 1.56.2; 1.56.4;
Fix rump.ifconfig shows host's interface names in link local addresses
 1.55 28-Apr-2015  christos remove 80211 stats if small.
 1.54 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.53 08-Aug-2012  christos branches: 1.53.2;
don't define RUMP_ACTION if MKRUMP = no
 1.52 14-Aug-2011  christos branches: 1.52.2;
use memcpy to avoid strict aliasing warnings
 1.51 22-Jun-2011  mrg apply some -Wno-error and/or -fno-strict-aliasing.


all of this should be looked at closer, but some of them are not
very trivial.
 1.50 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.49 05-Nov-2010  pooka Need getifaddrs() for the rump client since it executes sysctl(2)
 1.48 04-Nov-2010  pooka Update RUMP_ACTION to use the newstyle rump client.
 1.47 01-Jul-2010  dyoung Apparently, -g belongs in the DBG variable, not in CFLAGS. Make it so
on a line that is commented-out in this makefile.
 1.46 16-Sep-2009  tsutsui - no space needed between -I and dir per gcc(1)
- it's still better to use ${NETBSDSRCDIR} per other existing Makefiles
 1.45 16-Sep-2009  tsutsui Add comments that Makefile.inc should have shared stuff with
src/distrib/utils/x_ifconfig for install media.
 1.44 15-Sep-2009  he Move the addition of pfsync.c from Makefile.inc to Makefile,
so that this part doesn't get included in install media versions
of ifconfig, as per comments on source-changes@ from Izumi Tsutsui.
Also re-instate the use of ${.CURDIR} when setting up the include path.
 1.43 02-Jun-2009  pooka If RUMP_ACTION, treat close() as a rump syscall.
 1.42 26-May-2009  pooka Add compile mode which executes rump system calls. This is useful
when figuring out Where In The Kernel Is Carmen Sandiego's ioctl
for an ifconfig command line, since we can simply single-step into
the kernel.

Activated by "make RUMP_ACTION=1". No changes to normal case.
 1.41 11-Apr-2009  lukem Enable WARNS=4 by default except for:
dump dump_lfs fsck_ffs fsck_lfs fsdb mount_smbfs
newfs_ext2fs newfs_lfs resize_lfs setkey
 1.40 13-Feb-2009  uebayasi Comment out CFLAGS+=-g.
 1.39 29-Nov-2008  tsutsui branches: 1.39.2;
Specify -fno-loop-optimize on m68000 as workaround for gcc -O1 codegen bug
mentioned in PR bin/40036 and PR toolchain/40066.
 1.38 02-Jul-2008  dyoung branches: 1.38.2;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.37 12-May-2008  dyoung Per discussion at
<http://mail-index.netbsd.org/tech-net/2008/04/08/msg000371.html>,
let us add, delete, and activate link-layer addresses with ifconfig:

# ifconfig sip0 link 02:00:00:00:00:01 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 active [activate address]
# ifconfig sip0 link 02:00:00:00:00:01 delete [remove address]
 1.36 08-May-2008  dyoung Don't use -pedantic, it stops af_atalk.c and af_iso.c from building
if INET_ONLY is #defined.
 1.35 07-May-2008  dyoung Remove CPPFLAGS that are redundant when WARNS=4.
 1.34 06-May-2008  dyoung branches: 1.34.2;
Add WARNS=4 and a dependency on ${LIBPROP}.
 1.33 06-May-2008  dyoung Take out my CFLAGS settings for debugging.
 1.32 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.31 26-Aug-2006  matt branches: 1.31.18; 1.31.20;
Remove XNS support.
 1.30 18-May-2006  liamjfoy Integrate Common Address Redundancy Procotol (CARP) from OpenBSD

'pseudo-device carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
 1.29 27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.28 20-Mar-2005  yamt add a reminder comment for x_ifconfig.
 1.27 20-Mar-2005  thorpej Don't build af_inet6.c if USE_INET6 is no.
 1.26 20-Mar-2005  thorpej Split the IPv4 support into its own file.
 1.25 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.24 20-Mar-2005  thorpej Split OSI support off into its own file.
 1.23 19-Mar-2005  thorpej Split XNS support into its own file.
 1.22 19-Mar-2005  thorpej Split off AppleTalk support into its own file.
 1.21 19-Mar-2005  thorpej Split off 802.11 interface handling into its own file.
 1.20 19-Mar-2005  thorpej Split tunnel support into its own file.
 1.19 19-Mar-2005  thorpej Split VLAN configuration bits out into a separate file.
 1.18 18-Mar-2005  yamt add agr(4), a pseudo network device driver for link aggregation.
 1.17 20-Jan-2005  xtraeme Fix the cast for the getnameinfo() call in the status() function, which
should be "const struct" not "struct" for sockaddr.

WARNS=3
 1.16 10-Jan-2005  lukem Only compile in IPv6 support if ${USE_INET6} != "no"

MKINET6 is for providing IPv6 infrastructure.
USE_INET6 is for compiling IPv6 support into the programs (needs MKINET6).
 1.15 28-Oct-2004  dsl More isdigit() calls that need (unsigned char) cast
 1.14 20-Sep-2002  christos use snprintb()
 1.13 28-Apr-2001  itojun assume the presense of getifaddrs(3).
 1.12 13-Apr-2000  itojun use getifaddrs, not SIOCGIFCONF, to avoid alignment constraints.
TODO: maybe it's better to pass struct ifaddrs * to in{,6}_alias.
 1.11 13-Dec-1999  itojun bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.
 1.10 12-Dec-1999  itojun prepare -DKAME_SCOPEID for extended scope id printing (commented out)
 1.9 03-Jul-1999  itojun branches: 1.9.4;
s/CFLAGS/CPPFLAGS/ for -D and -I.
 1.8 01-Jul-1999  itojun make ifconfig IPv6-ready.
TODO: update manpage for new options.
 1.7 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.6 22-Dec-1994  cgd specify man pages the new way.
 1.5 23-Sep-1994  mycroft Merge with 4.4-Lite version.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 23-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.31.20.1 18-May-2008  yamt sync with head.
 1.31.18.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.31.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.34.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.34.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.38.2.2 08-Dec-2010  riz Pull up following revision(s) (requested by uwe in ticket #1490):
usr.bin/mkdep/Makefile: revision 1.16
sbin/dump_lfs/Makefile: revision 1.10
usr.sbin/services_mkdb/Makefile: revision 1.5
sbin/ifconfig/Makefile: revision 1.40
usr.sbin/racoonctl/Makefile: revision 1.3
sbin/sysctl/Makefile: revision 1.18
Comment out CFLAGS+=-g.
Disable debug.
 1.38.2.1 06-Dec-2008  snj Pull up following revision(s) (requested by tsutsui in ticket #164):
sbin/ifconfig/Makefile: revision 1.39
Specify -fno-loop-optimize on m68000 as workaround for gcc -O1 codegen bug
mentioned in PR bin/40036 and PR toolchain/40066.
 1.39.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.52.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.52.2.1 30-Oct-2012  yamt sync with head
 1.53.2.1 23-Jun-2013  tls resync from head
 1.56.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.56.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.61.16.1 02-Aug-2025  perseant Sync with HEAD
 1.8 18-Sep-2025  mrg introduce a couple of new turn-off-gcc-warning variables and use them.

GCC 14 has a new annoying calloc() checker that we turn off in a bunch
of places, and there are a few more dangling-pointer issuse that come up,
but seem bogus.
 1.7 17-May-2021  yamaguchi Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.6 01-Mar-2021  martin branches: 1.6.2;
Make IEEE802.11 support optional
 1.5 02-May-2017  christos We don't need agr or l2tp when we are small.
 1.4 16-Feb-2017  knakahara branches: 1.4.2; 1.4.4; 1.4.6;
add l2tp(4) subcomands to ifconfig(8).

originally implemented by IIJ SEIL team.
 1.3 08-Feb-2017  rin Cosmetic changes. No functional changes.
 1.2 08-Feb-2017  rin Factor out a common part in Makefile's of ifconfig and x_ifconfig.
 1.1 08-Feb-2017  rin Rename sbin/ifconfig/Makefile.inc to Makefile.common; the former can
potentially conflict with bsd.subdir.mk.
 1.4.6.1 11-May-2017  pgoyette Sync with HEAD
 1.4.4.2 21-Apr-2017  bouyer Sync with HEAD
 1.4.4.1 16-Feb-2017  bouyer file Makefile.common was added on branch bouyer-socketcan on 2017-04-21 16:53:13 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 16-Feb-2017  pgoyette file Makefile.common was added on branch pgoyette-localcount on 2017-03-20 06:57:02 +0000
 1.6.2.1 31-May-2021  cjep sync with head
 1.10 08-Feb-2017  rin Rename sbin/ifconfig/Makefile.inc to Makefile.common; the former can
potentially conflict with bsd.subdir.mk.
 1.9 31-Oct-2012  msaitoh branches: 1.9.12; 1.9.16;
Add SIOCGETHERCAP ioctl.
There was no way to know the setting of ec_capabilities and ec_capenable
other than grepping the source.

See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html
 1.8 13-Dec-2010  pooka branches: 1.8.6; 1.8.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.7 16-Sep-2009  tsutsui Add comments that Makefile.inc should have shared stuff with
src/distrib/utils/x_ifconfig for install media.
 1.6 15-Sep-2009  he Move the addition of pfsync.c from Makefile.inc to Makefile,
so that this part doesn't get included in install media versions
of ifconfig, as per comments on source-changes@ from Izumi Tsutsui.
Also re-instate the use of ${.CURDIR} when setting up the include path.
 1.5 14-Sep-2009  he Change from using ${.CURDIR} to ${NETBSDSRCDIR} because this file
may be included by different parts of the source tree, in particular
deep down in the distrib/ tree, where ../.. isn't sufficient to "climb"
up to the top of the tree. Fixes the build at least for our arc port.
 1.4 14-Sep-2009  degroote Import pfsync support from OpenBSD 4.2

Pfsync interface exposes change in the pf(4) over a pseudo-interface, and can
be used to synchronise different pf.

This work was part of my 2009 GSoC

No objection on tech-net@
 1.3 26-May-2009  pooka Install agr ioctl header and stop putting our hand under the sys skirt
in ifconfig.
 1.2 29-Nov-2008  tsutsui Add RCS Id. XXX why separate Makefile.inc?
 1.1 02-Jul-2008  dyoung branches: 1.1.2; 1.1.4;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.1.4.3 17-Jan-2009  mjf Sync with HEAD.
 1.1.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.4.1 02-Jul-2008  mjf file Makefile.inc was added on branch mjf-devfs2 on 2008-09-28 11:17:11 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 02-Jul-2008  wrstuden file Makefile.inc was added on branch wrstuden-revivesa on 2008-09-18 04:28:24 +0000
 1.8.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.6.1 16-Jan-2013  yamt sync with (a bit old) head
 1.9.16.1 21-Apr-2017  bouyer Sync with HEAD
 1.9.12.1 20-Mar-2017  pgoyette Sync with HEAD
 1.21 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.20 16-Aug-2019  msaitoh Whitespace fix.
 1.19 19-Oct-2013  christos branches: 1.19.26;
use the new scopeid functions
 1.18 14-Aug-2011  christos branches: 1.18.2; 1.18.8;
use memcpy to avoid strict aliasing warnings
 1.17 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.16 30-Jan-2010  is Use getnameinfo() for printing AppleTalk addresses. While here, fix
printing of broadcast for this address family (AT broadcast is fixed
node 255 on the local net).
 1.15 01-Aug-2008  dyoung is@ pointed out that I set the phase and range of a sockaddr_at
without subsequently doing anything with it, so commit_address()
works with an address with phase == 0. phase == 0 is not allowed,
hence

random84# ifconfig nfe0 atalk 3.14
ifconfig: SIOCAIFADDR: Invalid argument

Solution: copy the new sockaddr_at to a temporary input environment,
and pass that environment to commit_address(). I may as well copy
the new sockaddr_at to the output environment, while I am at it.
 1.14 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.13 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.12 11-May-2008  dyoung Start to adapt the AppleTalk module to use commit_address().
 1.11 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.10 06-May-2008  dyoung branches: 1.10.2;
Use prop_dictionary_util(3).
 1.9 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.8 06-May-2008  dyoung If the address family is not set, assume AF_APPLETALK. Exit
at_status() quietly if the address family is set, and it is not
set to AF_APPLETALK.
 1.7 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.6 15-Apr-2008  dyoung branches: 1.6.2;
Cosmetic: write strcmp() == 0 instead of !strcmp().
 1.5 11-Apr-2008  dyoung Cosmeticc: there's no use casting a uint16_t to a u_short, so don't
do that. Change indentation for readability.
 1.4 26-Aug-2006  christos branches: 1.4.18;
Programs that use efun.
 1.3 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.2 14-Jun-2006  tron Adapt ifconfig(8) to new return value from socket(2). This stops
ifconfig(8) from printing errors like "ifconfig: socket: Address
family not supported by protocol family" when examining the status
of a network interface.
 1.1 19-Mar-2005  thorpej Split off AppleTalk support into its own file.
 1.4.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.4.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.2.1 18-May-2008  yamt sync with head.
 1.10.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.5 11-May-2008  dyoung Start to adapt the AppleTalk module to use commit_address().
 1.4 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 19-Mar-2005  thorpej branches: 1.1.20; 1.1.22;
Split off AppleTalk support into its own file.
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28 14-May-2020  msaitoh Remove extra semicolon.
 1.27 10-Apr-2020  plunky trim extraneous return statement
 1.26 16-Aug-2019  msaitoh Whitespace fix.
 1.25 11-Jun-2018  kamil branches: 1.25.2;
Correct Undefined Behavior in ifconfig(8)

Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# ifconfig
alc0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ec_capabilities=3<VLAN_MTU,VLAN_HWTAGGING>
ec_enabled=0
address: xx:xx:xx:xx:xx:xx
/public/src.git/sbin/ifconfig/af_inet.c:102:34: runtime error: left shift of 16777215 by 8 places cannot be represented in type 'int'
inet 192.168.0.38/24 broadcast 192.168.0.255 flags 0x0
inet6 xxxx::xxxx:xxxx:xxxx:xxx%alc0/64 flags 0x0 scopeid 0x1
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
inet 127.0.0.1/8 flags 0x0
inet6 ::1/128 flags 0x20<NODAD>
inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2

Change shifting left 1 to shifting 1U. This corrects the issue.

if (cidr < 32) { /* more than 1 bit in mask */
/* check for non-contig netmask */
if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0) // <- here
return -1; /* noncontig, no pfxlen */
}

Solution suggested by <uwe>

Sponsored by <The NetBSD Foundation>
 1.24 01-Oct-2016  kre branches: 1.24.12;

Return to printing explicit "netmask 0x...." in the case that the
mask set is non-contiguous. We don't prohibit setting such things
(even if they are basically useless) so they can be set by accident.
ifconfig ifN 10.0.0.1 netmask 225.0.0.0
produced
ifN .. inet 10.0.0.1/8
with the previous form (since 225 is 0xE1), now it produces
ifN ... inet 10.0.0.1 netmask 0xe1000000

If the "netmask" form ever appears in ifconfig output, it (now)
means that the netmask is non-contig, which should make that case
obvious (whther intended, or set by accident)
 1.23 01-Oct-2016  roy Modernise the output for the address to address/prefix instead
of differring outputs for INET and INET6.
The hex string of the INET netmask was particulary hard to read.
 1.22 30-Sep-2016  roy Remove the alias keyword from ifconfig output as it serves no purpose.
 1.21 30-Sep-2016  roy ifaddrs has more data than just the address.
Use it instead of making pointless ioctl calls.
 1.20 13-Sep-2016  christos print address flag bits using snprintb
 1.19 29-Feb-2016  riastradh branches: 1.19.2;
Consistently use estrlcpy for ifr.ifr_name here, not strncpy.
 1.18 07-Jan-2016  roy -W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
 1.17 12-May-2015  roy ioctl -> prog_ioctl as pointed out by pooka@
 1.16 02-May-2015  roy Report IN_IFF_TENTATIVE and friends.
Wait for IN_IFF_TENTATIVE to be removed with the -w flag.
 1.15 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.14 11-Sep-2009  dyoung Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
 1.13 07-Aug-2009  dyoung Use getnameinfo(3) instead of inet_ntoa(3) to convert IPv4 addresses
to names.
 1.12 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.11 12-May-2008  dyoung Make prototype and definition of in_alias() agree: it's static.
 1.10 11-May-2008  dyoung Don't export in_alias(). Pass in_alias() a more useful template.
Misc. cosmetic changes. Delete dead code. Treat the address
preference as int16_t, since that is its real type.
 1.9 11-May-2008  dyoung Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

Switch to in6_commit_address() from in6_getprefix() and in6_getaddr().

Temporarily add some debugging code to setia6eui64_impl().
 1.8 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.7 06-May-2008  dyoung branches: 1.7.2;
Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.6 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.5 13-Nov-2006  dyoung branches: 1.5.18; 1.5.20;
Add a source-address selection policy mechanism to the kernel.

Also, add ioctls SIOCGIFADDRPREF/SIOCSIFADDRPREF to get/set preference
numbers for addresses. Make ifconfig(8) set/display preference
numbers.

To activate source-address selection policies in your kernel, add
'options IPSELSRC' to your kernel configuration.

Miscellaneous changes in support of source-address selection:

1 Factor out some common code, producing rt_replace_ifa().

2 Abbreviate a for-loop with TAILQ_FOREACH().

3 Add the predicates on IPv4 addresses IN_LINKLOCAL() and
IN_PRIVATE(), that are true for link-local unicast
(169.254/16) and RFC1918 private addresses, respectively.
Add the predicate IN_ANY_LOCAL() that is true for link-local
unicast and multicast.

4 Add IPv4-specific interface attach/detach routines,
in_domifattach and in_domifdetach, which build #ifdef
IPSELSRC.

See in_getifa(9) for a more thorough description of source-address
selection policy.
 1.4 26-Aug-2006  christos Programs that use efun.
 1.3 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.2 14-Jun-2006  tron Adapt ifconfig(8) to new return value from socket(2). This stops
ifconfig(8) from printing errors like "ifconfig: socket: Address
family not supported by protocol family" when examining the status
of a network interface.
 1.1 20-Mar-2005  thorpej Split the IPv4 support into its own file.
 1.5.20.1 18-May-2008  yamt sync with head.
 1.5.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.5.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.19.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.24.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.25.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.7 12-May-2008  dyoung setifipdst() is gone, so delete the prototype. #include nothing
(XXX).
 1.6 11-May-2008  dyoung Don't export in_alias(). Pass in_alias() a more useful template.
Misc. cosmetic changes. Delete dead code. Treat the address
preference as int16_t, since that is its real type.
 1.5 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.4 06-May-2008  dyoung branches: 1.4.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.3 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 20-Mar-2005  thorpej branches: 1.1.20; 1.1.22;
Split the IPv4 support into its own file.
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39 16-Aug-2019  msaitoh Whitespace fix.
 1.38 01-Oct-2016  roy branches: 1.38.14;
Modernise the output for the address to address/prefix instead
of differring outputs for INET and INET6.
The hex string of the INET netmask was particulary hard to read.
 1.37 30-Sep-2016  roy ifaddrs has more data than just the address.
Use it instead of making pointless ioctl calls.
 1.36 13-Sep-2016  christos print address flag bits using snprintb
 1.35 29-Feb-2016  riastradh branches: 1.35.2;
Consistently use estrlcpy for ifr.ifr_name here, not strncpy.
 1.34 07-Jan-2016  roy -W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
 1.33 12-May-2015  roy ioctl -> prog_ioctl as pointed out by pooka@
 1.32 22-Apr-2015  roy Move the INET6 specific code for wait_dad_exec() into af_inet6
by using a new afswtch hook af_addr_tentative.
 1.31 20-Jan-2015  roy Display the IPv6 address flags autoconf and temporary
 1.30 20-Oct-2014  roy Remove the ability for userland to toggle IN6_IFF_TENTATIVE.
Preserve IN6_IFF_TENTATIVE when updating address flags.
 1.29 19-Oct-2013  christos branches: 1.29.4;
use symbolic flags
 1.28 19-Oct-2013  christos use the new scopeid functions
 1.27 13-Dec-2010  pooka branches: 1.27.6; 1.27.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.26 22-Jan-2010  dyoung Compare a pointer with NULL instead of testing its "truth."
 1.25 11-Sep-2009  dyoung Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
 1.24 07-Aug-2009  dyoung Add option -N. -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
 1.23 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.22 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.21 12-May-2008  dyoung Retire in6_addreq and in6_ridreq, which we do not use in the
commit_address() regime.
 1.20 12-May-2008  dyoung Initialize IPv6 addresses and ifreqs with more rigor. Fixes this
bug reported by Matthias Scheler,

# ifconfig sip0 inet6 fdb4:542d:dc11:ec20::1
ifconfig: SIOCAIFADDR_IN6: Invalid argument
# ifconfig sip0 inet6 fdb4:542d:dc11:ec20::1 prefixlen 64
 1.19 11-May-2008  dyoung Get rid of sec2str() altogether.
 1.18 11-May-2008  dyoung In in6_alias(), instead of repeating the memset()/estrlcpy()/sockaddr_in6
assignment-dance, copy creq to ifr6 before each ioctl().
 1.17 11-May-2008  dyoung Delete unused array sin6tab[]. Delete unnecessary casts.
 1.16 11-May-2008  dyoung Delete dead code in sec2str().
 1.15 11-May-2008  dyoung Retire some code that in6_commit_address() replaces.
 1.14 11-May-2008  dyoung Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

Switch to in6_commit_address() from in6_getprefix() and in6_getaddr().

Temporarily add some debugging code to setia6eui64_impl().
 1.13 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.12 07-May-2008  dyoung Move IPv6 syntax to af_inet6.c from ifconfig.c. Move IFKW() macro
from ifconfig.c to parse.h for reuse.
 1.11 07-May-2008  dyoung Fix a bug that I introduced in rev 1.88, where the default IPv6
prefix length changed from 64 to 128. While I am here, allow an
address to be given with prefix length /0, but interpret it as
/128.
 1.10 06-May-2008  dyoung branches: 1.10.2;
Use prop_dictionary_util(3).
 1.9 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.8 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.7 24-Apr-2008  dyoung Don't cast memset(3) to void. Remove a needless cast to struct
in6_addr *.
 1.6 15-Apr-2008  dyoung branches: 1.6.2;
Use static initializers to setup ISO and IPv6 addresses, instead
of calling protocol family-specific routines from main().
 1.5 26-Aug-2006  christos branches: 1.5.16; 1.5.18;
Programs that use efun.
 1.4 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.3 14-Jun-2006  tron Adapt ifconfig(8) to new return value from socket(2). This stops
ifconfig(8) from printing errors like "ifconfig: socket: Address
family not supported by protocol family" when examining the status
of a network interface.
 1.2 20-Mar-2005  thorpej Remove an #ifdef that is no longer necessary.
 1.1 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.5.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.5.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.16.1 22-Feb-2008  keiichi imported Mobile IPv6 code developed by the SHISA project
(http://www.mobileip.jp/).
 1.6.2.1 18-May-2008  yamt sync with head.
 1.10.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.4.2 23-Jan-2015  martin Pull up following revision(s) (requested by pettai in ticket #442):
sbin/ifconfig/af_inet6.c: revision 1.31
Display the IPv6 address flags autoconf and temporary
 1.29.4.1 27-Oct-2014  martin Pull up following revision(s) (requested by roy in ticket #160):
sbin/ifconfig/af_inet6.c: revision 1.30
sbin/ifconfig/ifconfig.8: revision 1.109
sys/netinet6/in6.c: revision 1.177
Remove the ability for userland to toggle IN6_IFF_TENTATIVE.
Preserve IN6_IFF_TENTATIVE when updating address flags.
 1.35.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.38.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.7 03-Jun-2008  dyoung Remove remnants of struct afswtch.af_getprefix().
 1.6 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.5 07-May-2008  dyoung Move IPv6 syntax to af_inet6.c from ifconfig.c. Move IFKW() macro
from ifconfig.c to parse.h for reuse.
 1.4 06-May-2008  dyoung branches: 1.4.2;
Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.3 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.2 11-May-2006  mrg branches: 1.2.20; 1.2.22;
remove extern for unused ifr6.
 1.1 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.2.22.2 17-Jun-2008  yamt sync with head.
 1.2.22.1 18-May-2008  yamt sync with head.
 1.2.20.3 28-Sep-2008  mjf Sync with HEAD.
 1.2.20.2 29-Jun-2008  mjf Sync with HEAD.
 1.2.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23 17-Aug-2022  nat Revert to previous as the atf tests are still failing.
 1.22 17-Aug-2022  nat Use existing address when setting parameters.

No need to specify address every time when setting broadcast address or
netmask.

Hopefully successfully re addresses PR bin/10911.
 1.21 16-Aug-2022  nat Revert to previous as atf tests were failing.
 1.20 16-Aug-2022  nat No need address every time to specify broadcast and netmask.

Previously ifconfig would fail silently.

Addresses PR bin/10911.
 1.19 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.18 16-Aug-2019  msaitoh Whitespace fix.
 1.17 30-Dec-2012  christos branches: 1.17.30;
fix function name in error messages.
 1.16 30-Dec-2012  christos PR/46579: Takahiro HAYASHI: ifconfig clone destroy should not print useless
diagnostic and exit with an error code. Get the interface name and flags
opportunistically to allow the code to return normally if it does not need
to do anything.
 1.15 17-Mar-2012  christos branches: 1.15.2;
PR/43141: Tobias Nygren: Print an error on unknown interfaces.
 1.14 24-May-2011  joerg branches: 1.14.4; 1.14.6;
Don't use address strings as format string.
 1.13 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.12 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.11 03-Jun-2008  dyoung *Always* pass the prefix mask specified on the command line, even
on an IFF_POINTOPOINT interface. Patch tested by John Klos and
found to fix the bug he reported on tech-net@, "Subject: Can't use
gif in -current".
 1.10 02-Jun-2008  dyoung Cosmetic: add missing /*FALLTHROUGH*/.
 1.9 28-May-2008  dyoung branches: 1.9.2;
Fix kern/38775, "ifconfig inet delete fails".
 1.8 16-May-2008  dyoung branches: 1.8.2;
Apply netmasks to !(IFF_BROADCAST|IFF_POINTOPOINT) interfaces as
well as to IFF_BROADCAST interfaces. Fixes the bug reported by
Markus W Kilbinger,

ifconfig stf0 inet6 2002:xxxx:76ec:0001::1 prefixlen 16 alias

results in the wrong configuration,

stf0: flags=1<UP> mtu 1280
inet6 2002:xxxx:76ec:1::1 prefixlen 64
 1.7 12-May-2008  dyoung Apply the right copyright notice.
 1.6 11-May-2008  dyoung Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

Switch to in6_commit_address() from in6_getprefix() and in6_getaddr().

Temporarily add some debugging code to setia6eui64_impl().
 1.5 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.4 06-May-2008  dyoung branches: 1.4.2;
Use prop_dictionary_util(3).
 1.3 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.1 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.4.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.2.3 04-Jun-2008  yamt sync with head
 1.8.2.2 18-May-2008  yamt sync with head.
 1.8.2.1 16-May-2008  yamt file af_inetany.c was added on branch yamt-pf42 on 2008-05-18 12:30:52 +0000
 1.9.2.4 28-Sep-2008  mjf Sync with HEAD.
 1.9.2.3 29-Jun-2008  mjf Sync with HEAD.
 1.9.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.2.1 28-May-2008  mjf file af_inetany.c was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.14.6.1 08-Feb-2013  riz Pull up following revision(s) (requested by christos in ticket #799):
sbin/ifconfig/af_inetany.c: revision 1.16
PR/46579: Takahiro HAYASHI: ifconfig clone destroy should not print useless
diagnostic and exit with an error code. Get the interface name and flags
opportunistically to allow the code to return normally if it does not need
to do anything.
 1.14.4.2 23-Jan-2013  yamt sync with head
 1.14.4.1 17-Apr-2012  yamt sync with head
 1.15.2.1 25-Feb-2013  tls resync with head
 1.17.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.3 12-May-2008  dyoung branches: 1.3.2; 1.3.4; 1.3.6;
Apply the right copyright notice.
 1.2 11-May-2008  dyoung Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

Switch to in6_commit_address() from in6_getprefix() and in6_getaddr().

Temporarily add some debugging code to setia6eui64_impl().
 1.1 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.3.6.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.6.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.3.6.1 12-May-2008  wrstuden file af_inetany.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.3.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.3.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.4.1 12-May-2008  mjf file af_inetany.h was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.3.2.2 18-May-2008  yamt sync with head.
 1.3.2.1 12-May-2008  yamt file af_inetany.h was added on branch yamt-pf42 on 2008-05-18 12:30:52 +0000
 1.15 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.14 13-Dec-2010  pooka branches: 1.14.6; 1.14.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.13 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.12 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.11 08-May-2008  dyoung Delete #if 0'd code.
 1.10 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.9 06-May-2008  dyoung branches: 1.9.2;
Extract subroutine do_setifcaps() and fix the bug that uwe@ reported
in capabilities-setting.

Use prop_dictionary_util(3).

Rename the parser snpaoffset to parse_snpaoffset.
 1.8 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.7 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.6 15-Apr-2008  dyoung branches: 1.6.2;
Use static initializers to setup ISO and IPv6 addresses, instead
of calling protocol family-specific routines from main().
 1.5 11-Apr-2008  dyoung Cosmetic: compare socket address family with AF_UNSPEC instead of
0.
 1.4 26-Aug-2006  christos branches: 1.4.18;
Programs that use efun.
 1.3 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.2 14-Jun-2006  tron Adapt ifconfig(8) to new return value from socket(2). This stops
ifconfig(8) from printing errors like "ifconfig: socket: Address
family not supported by protocol family" when examining the status
of a network interface.
 1.1 20-Mar-2005  thorpej Split OSI support off into its own file.
 1.4.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.4.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.2.1 18-May-2008  yamt sync with head.
 1.9.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.6 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.5 06-May-2008  dyoung branches: 1.5.2;
Extract subroutine do_setifcaps() and fix the bug that uwe@ reported
in capabilities-setting.

Use prop_dictionary_util(3).

Rename the parser snpaoffset to parse_snpaoffset.
 1.4 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.3 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.2 15-Apr-2008  dyoung branches: 1.2.2;
Use static initializers to setup ISO and IPv6 addresses, instead
of calling protocol family-specific routines from main().
 1.1 20-Mar-2005  thorpej branches: 1.1.20;
Split OSI support off into its own file.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.2.1 18-May-2008  yamt sync with head.
 1.5.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.5.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8 16-Aug-2019  msaitoh Whitespace fix.
 1.7 19-Jan-2014  matt branches: 1.7.26;
Rename link to link_pkw to avoid shadowing the link syscall.
 1.6 21-Apr-2009  dyoung branches: 1.6.6; 1.6.12;
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
 1.5 21-Apr-2009  dyoung Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
 1.4 21-Apr-2009  dyoung Fix indentation: change spaces to tabs.
 1.3 02-Jul-2008  dyoung branches: 1.3.2; 1.3.4; 1.3.8;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.2 13-May-2008  dyoung branches: 1.2.2; 1.2.4; 1.2.6;
Use an AF_LINK socket to add/delete/get link-layer addresses.
 1.1 12-May-2008  dyoung Per discussion at
<http://mail-index.netbsd.org/tech-net/2008/04/08/msg000371.html>,
let us add, delete, and activate link-layer addresses with ifconfig:

# ifconfig sip0 link 02:00:00:00:00:01 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 active [activate address]
# ifconfig sip0 link 02:00:00:00:00:01 delete [remove address]
 1.2.6.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.6.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.2.6.1 13-May-2008  wrstuden file af_link.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.2.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.2.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.4.1 13-May-2008  mjf file af_link.c was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.2.2.2 18-May-2008  yamt sync with head.
 1.2.2.1 13-May-2008  yamt file af_link.c was added on branch yamt-pf42 on 2008-05-18 12:30:52 +0000
 1.3.8.1 21-Apr-2010  matt sync to netbsd-5
 1.3.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.3.2.1 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.1 12-May-2008  dyoung branches: 1.1.2; 1.1.4; 1.1.6;
Per discussion at
<http://mail-index.netbsd.org/tech-net/2008/04/08/msg000371.html>,
let us add, delete, and activate link-layer addresses with ifconfig:

# ifconfig sip0 link 02:00:00:00:00:01 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 active [activate address]
# ifconfig sip0 link 02:00:00:00:00:01 delete [remove address]
 1.1.6.3 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.1.6.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.6.1 12-May-2008  wrstuden file af_link.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:12 +0000
 1.1.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 12-May-2008  mjf file af_link.h was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.1.2.2 18-May-2008  yamt sync with head.
 1.1.2.1 12-May-2008  yamt file af_link.h was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.5 26-Aug-2006  matt Remove XNS support.
 1.4 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.3 14-Jun-2006  tron Adapt ifconfig(8) to new return value from socket(2). This stops
ifconfig(8) from printing errors like "ifconfig: socket: Address
family not supported by protocol family" when examining the status
of a network interface.
 1.2 20-Mar-2005  thorpej Move a comment.
 1.1 19-Mar-2005  thorpej Split XNS support into its own file.
 1.2 26-Aug-2006  matt Remove XNS support.
 1.1 19-Mar-2005  thorpej Split XNS support into its own file.
 1.16 21-Jun-2021  christos fix proplib deprecation
 1.15 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.14 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.13 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.12 19-May-2008  dyoung Fix two bugs:

1 Let us associate a keyword with either a signed or an unsigned
number. Associate the '-chan' keyword with an unsigned number.
This fixes the defect that crashed 'ifconfig wi0 -chan', reported
by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
address family was specified. iso_addr(3) does not report errors,
so it appears to interpret *everything* as an ISO address. This
is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
!INET6 kernel that deletes the first IPv4 address on lo0.
(Reported by Scott Ellis.)
 1.11 09-May-2008  dyoung Repair agr(4) syntax. Should fix PR bin/38600.
 1.10 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.9 07-May-2008  dyoung Move net80211 and agr(4) syntax out of ifconfig.c and into ieee80211.c
and agr.c, respectively.
 1.8 07-May-2008  yamt branches: 1.8.2;
agrsetport: fix a use of uninitialized variable.
 1.7 06-May-2008  dyoung Use prop_dictionary_util(3).
 1.6 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.5 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.4 22-Apr-2008  dyoung Copy a const string to a temporary buffer instead of using __UNCONST().

Cosmetic: get rid of superflous curly braces and cast to (void *).
 1.3 19-Mar-2005  thorpej branches: 1.3.20; 1.3.22;
name -> ifname (avoid shadow decl with global name[]).
 1.2 19-Mar-2005  thorpej Move extern decls to extern.h
 1.1 18-Mar-2005  yamt add agr(4), a pseudo network device driver for link aggregation.
 1.3.22.2 04-Jun-2008  yamt sync with head
 1.3.22.1 18-May-2008  yamt sync with head.
 1.3.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.4 07-May-2008  dyoung Move net80211 and agr(4) syntax out of ifconfig.c and into ieee80211.c
and agr.c, respectively.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 18-Mar-2005  yamt branches: 1.1.20; 1.1.22;
add agr(4), a pseudo network device driver for link aggregation.
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15 26-Mar-2023  mlelstv Fix parser for carp state.
The state values are uppercase words INIT, BACKUP and MASTER.
 1.14 07-Jun-2020  thorpej branches: 1.14.6;
Update for proplib(3) API changes.
 1.13 11-Sep-2009  dyoung This should fix 'carpdev <ifname>' or, at least, not break it more
badly than before.
 1.12 15-Jul-2008  dyoung branches: 1.12.2; 1.12.6; 1.12.10;
Cosmetic: s/xenv/oenv/
 1.11 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.10 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.9 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.8 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.7 06-May-2008  dyoung branches: 1.7.2;
Use prop_dictionary_util(3).
 1.6 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.5 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.4 22-Apr-2008  dyoung Delete some gratuitous casts, s/(char *)//.
 1.3 21-Apr-2008  dyoung s/(caddr_t)//
 1.2 21-Apr-2008  dyoung Change bzero calls to memset calls.
 1.1 18-May-2006  liamjfoy branches: 1.1.20; 1.1.22;
Integrate Common Address Redundancy Procotol (CARP) from OpenBSD

'pseudo-device carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.10.1 16-Oct-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1670):
sbin/ifconfig/carp.c: revision 1.13
This should fix 'carpdev &lt;ifname&gt;' or, at least, not break it more
badly than before.
 1.12.6.1 16-Oct-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1670):
sbin/ifconfig/carp.c: revision 1.13
This should fix 'carpdev &lt;ifname&gt;' or, at least, not break it more
badly than before.
 1.12.2.1 16-Oct-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1670):
sbin/ifconfig/carp.c: revision 1.13
This should fix 'carpdev &lt;ifname&gt;' or, at least, not break it more
badly than before.
 1.14.6.1 21-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #902):

sbin/ifconfig/carp.c: revision 1.15
sbin/ifconfig/ifconfig.8: revision 1.125
tests/net/carp/t_basic.sh: revision 1.9
sys/netinet/ip_carp.c: revision 1.118
sys/netinet/ip_carp.c: revision 1.119

Fix parser for carp state.

The state values are uppercase words INIT, BACKUP and MASTER.

Use backing device to send advertisements. Otherwise the packets originate
from the virtual MAC address, which confuses switches.

Select virtual address as sender if backing interface is anonymous.

Use correct scope for IPv6.

Don't expect the net/carp/t_basic/carp_handover_ipv6_halt_nocarpdevip
and carp_handover_ipv6_ifdown_nocarpdevip test cases to fail. At
least on the TNF i386 and amd64 testbeds, they pass more often than
not since the commit of src/sys/netinet/ip_carp.c 1.119 by mlelstv on
2023.04.07.06.44.08.
 1.5 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.4 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 18-May-2006  liamjfoy branches: 1.1.20; 1.1.22;
Integrate Common Address Redundancy Procotol (CARP) from OpenBSD

'pseudo-device carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14 21-Jun-2021  christos fix proplib deprecation
 1.13 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.12 16-Aug-2019  msaitoh Whitespace fix.
 1.11 07-Mar-2016  christos branches: 1.11.16;
PR/50909: David Binderman: Optimize memset
 1.10 07-Mar-2016  christos PR/50909: David Binderman: Optimize memset
 1.9 07-Feb-2013  apb Avoid dereferencing NULL. Coverity CID 275201.
Also fix a typo in previous: !== should be !=
 1.8 07-Feb-2013  apb Don't call prop_distionary_make_immutable on a NULL pointer.
Coverity CID 275179.
 1.7 13-Dec-2010  pooka branches: 1.7.6; 1.7.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.6 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.5 12-May-2008  dyoung branches: 1.5.2; 1.5.4;
Cosmetic: fix copyright whitespace.
 1.4 09-May-2008  dyoung Use the correct key. Spotted by NONAKA Kimihiro.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3).
 1.2 06-May-2008  dyoung Add a license.
 1.1 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.3.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.5.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.1 12-May-2008  mjf file env.c was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.5.2.2 18-May-2008  yamt sync with head.
 1.5.2.1 12-May-2008  yamt file env.c was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.7.12.1 25-Feb-2013  tls resync with head
 1.7.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4 30-Jun-2019  sevan Add rcsid
 1.3 04-Nov-2010  pooka branches: 1.3.46;
Update RUMP_ACTION to use the newstyle rump client.
 1.2 26-May-2009  pooka Add compile mode which executes rump system calls. This is useful
when figuring out Where In The Kernel Is Carmen Sandiego's ioctl
for an ifconfig command line, since we can simply single-step into
the kernel.

Activated by "make RUMP_ACTION=1". No changes to normal case.
 1.1 06-May-2008  dyoung branches: 1.1.4; 1.1.6;
Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.1 06-May-2008  mjf file env.h was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.1.4.2 18-May-2008  yamt sync with head.
 1.1.4.1 06-May-2008  yamt file env.h was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.3.46.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.8 02-Jan-2020  ryo fix printing capabilities and enabled flags.

no need to skip a prefix "0x" of output of snprintb.
ifconfig expect the result of snprintb has "0x" prefix, but snprintb(3) specification has changed
so that if 0 is passed, it prints "0" instead of "0x0". (common/lib/libutil/snprintb.c r1.22)
 1.7 16-Aug-2019  msaitoh Whitespace fix.
 1.6 17-Jul-2019  msaitoh Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

- Set callback function:

ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

- Callback. This function is called when a vlan is attached/detached to the
parent interface:

int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

- ifconfig(8)

ifconfig ixg0 [-]vlan-hwfilter

Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
 1.5 17-Jul-2019  msaitoh KNF. No functional change.
 1.4 08-Jul-2019  msaitoh Add "ifconfig [-]vlan-hwtagging" to enable/disable VLAN hardware tagging
offload function. It's useful to see Ethernet frame's VLAN tag by
disabling with "ifconfig fooX -vlan-hwtagging" and "tcpdump -e -i fooX".
 1.3 21-Dec-2018  msaitoh Add SIOCSETHERCAP. It's used to change ec_capenable.
 1.2 01-Nov-2012  pgoyette branches: 1.2.2; 1.2.4; 1.2.32; 1.2.34;
Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users
 1.1 31-Oct-2012  msaitoh Add SIOCGETHERCAP ioctl.
There was no way to know the setting of ec_capabilities and ec_capenable
other than grepping the source.

See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html
 1.2.34.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.34.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.34.1 10-Jun-2019  christos Sync with HEAD
 1.2.32.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.2.4.1 01-Nov-2012  yamt file ether.c was added on branch yamt-pagecache on 2013-01-16 05:32:33 +0000
 1.2.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.2.1 01-Nov-2012  tls file ether.c was added on branch tls-maxphys on 2012-11-20 03:00:48 +0000
 1.16 16-Aug-2019  msaitoh Whitespace fix.
 1.15 21-Dec-2018  msaitoh Add SIOCSETHERCAP. It's used to change ec_capenable.
 1.14 07-Aug-2009  dyoung branches: 1.14.44; 1.14.46;
Add option -N. -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
 1.13 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.12 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.11 06-May-2008  dyoung branches: 1.11.2;
Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.10 26-Aug-2006  christos branches: 1.10.18; 1.10.20;
Programs that use efun.
 1.9 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.8 20-Mar-2005  thorpej Split the IPv4 support into its own file.
 1.7 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.6 19-Mar-2005  thorpej Split off AppleTalk support into its own file.
 1.5 19-Mar-2005  thorpej const'ify afswtch
 1.4 19-Mar-2005  thorpej Split off 802.11 interface handling into its own file.
 1.3 19-Mar-2005  thorpej Don't hare-code inet/inet6 in tunnel_status(), lookup the address family
name instead.
 1.2 19-Mar-2005  thorpej Split tunnel support into its own file.
 1.1 19-Mar-2005  thorpej Move extern decls to extern.h
 1.10.20.1 18-May-2008  yamt sync with head.
 1.10.18.2 28-Sep-2008  mjf Sync with HEAD.
 1.10.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.46.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.46.1 10-Jun-2019  christos Sync with HEAD
 1.14.44.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.31 13-Aug-2021  andvar fix typos in words "pointer" and s/fram /frame/
 1.30 16-Aug-2019  msaitoh Whitespace fix.
 1.29 22-Sep-2016  christos branches: 1.29.14;
fix bugs in ssid printing
 1.28 28-Apr-2015  christos branches: 1.28.2;
remove 80211 stats if small.
 1.27 08-Jan-2014  christos perror is obsolete, use warn and add missing paren.
 1.26 07-Jan-2014  degroote Before scanning, check if the card is up. If it is not the case, exit
with some useful error message. Add some note about this fact in the man
page too.
 1.25 13-Dec-2010  pooka branches: 1.25.6; 1.25.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.24 01-Jul-2010  dyoung Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.23 18-Jan-2009  lukem fix -Wsign-compare issues
 1.22 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.21 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.20 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.19 19-May-2008  dyoung Fix two bugs:

1 Let us associate a keyword with either a signed or an unsigned
number. Associate the '-chan' keyword with an unsigned number.
This fixes the defect that crashed 'ifconfig wi0 -chan', reported
by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
address family was specified. iso_addr(3) does not report errors,
so it appears to interpret *everything* as an ISO address. This
is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
!INET6 kernel that deletes the first IPv4 address on lo0.
(Reported by Scott Ellis.)
 1.18 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.17 07-May-2008  dyoung Move tunnel syntax into tunnel.c. Move net80211 'list' command
syntax into ieee80211.c.
 1.16 07-May-2008  dyoung Move net80211 and agr(4) syntax out of ifconfig.c and into ieee80211.c
and agr.c, respectively.
 1.15 06-May-2008  dyoung branches: 1.15.2;
Use prop_dictionary_util(3).

Re-use set80211() some more.
 1.14 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.13 06-May-2008  skrll Restore RCSId lost in 1.11
 1.12 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.11 16-Dec-2007  degroote branches: 1.11.4; 1.11.6;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.10 09-Jan-2007  dyoung branches: 1.10.4; 1.10.6;
Print more 802.11 statistics when the operator runs 'ifconfig -v
ath0', for example. Fix the spelling of one statistic.
 1.9 09-Jan-2007  dyoung Per discussion "ifconfig error handling" on tech-net@ in August
2006, if we fail to set any 802.11 parameter, exit immediately with
EXIT_FAILURE.
 1.8 09-Jan-2007  dyoung Let us adjust the 802.11 fragmentation threshold with ifconfig ath0
frag 256, for example.
 1.7 26-Aug-2006  christos Programs that use efun.
 1.6 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.5 29-Apr-2006  rpaulo Add two new options from FreeBSD:
hidessid | -hidessid: SSID broadcast control
apbridge | -apbridge: how to pass packets between wifi clients
 1.4 25-Jan-2006  christos PR/32628: Yves-Emmanuel JUTARD: Missing cast in sbin/ifconfig/ifconfig.c,
strcasecmp needs char * not u_int8_t *.
 1.3 15-Sep-2005  dyoung Commit a straggler: use the new SIOCG80211STATS/SIOCG80211ZSTATS
ABI.
 1.2 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.1 19-Mar-2005  thorpej Split off 802.11 interface handling into its own file.
 1.10.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.10.4.1 09-Jan-2008  matt sync with HEAD
 1.11.6.2 04-Jun-2008  yamt sync with head
 1.11.6.1 18-May-2008  yamt sync with head.
 1.11.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.11.4.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.15.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.29.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.29.14.1 10-Jun-2019  christos Sync with HEAD
 1.8 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.7 07-May-2008  dyoung Move net80211 and agr(4) syntax out of ifconfig.c and into ieee80211.c
and agr.c, respectively.
 1.6 06-May-2008  dyoung branches: 1.6.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.5 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.4 16-Dec-2007  degroote branches: 1.4.4; 1.4.6;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.3 09-Jan-2007  dyoung branches: 1.3.4; 1.3.6;
Let us adjust the 802.11 fragmentation threshold with ifconfig ath0
frag 256, for example.
 1.2 29-Apr-2006  rpaulo Add two new options from FreeBSD:
hidessid | -hidessid: SSID broadcast control
apbridge | -apbridge: how to pass packets between wifi clients
 1.1 19-Mar-2005  thorpej Split off 802.11 interface handling into its own file.
 1.3.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.3.4.1 09-Jan-2008  matt sync with HEAD
 1.4.6.1 18-May-2008  yamt sync with head.
 1.4.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.4.4.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.6.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.131 25-Sep-2024  roy ifconfig.8: -s only looks at interface link state
 1.130 20-Aug-2024  ozaki-r ifconfig: show link state on -v

We could guess it through "media" or "status" output, however, we
sometimes want to know it directly for debugging or testing.

It is shown only if the -v option is specified.
 1.129 08-Apr-2024  andvar branches: 1.129.2;
Update the date of the documentation to reflect recent changes.
 1.128 08-Apr-2024  uwe ifconfig(8): move laggportpri next to laggport
 1.127 08-Apr-2024  kre Correct a very minor typo (s/id/is/)
 1.126 08-Apr-2024  yamaguchi Added documents about parameters related to lagg(4)

PR misc/58125
 1.125 26-Mar-2023  mlelstv Fix parser for carp state.
The state values are uppercase words INIT, BACKUP and MASTER.
 1.124 25-Nov-2022  knakahara branches: 1.124.2;
ifconfig(8) support unnumbered flag.
 1.123 07-Jan-2022  bad mention ifmcstat(8) in SEE ALSO.
 1.122 09-Mar-2021  christos PR/50933: Uwe Toenjes: Document hardware limitations
 1.121 29-Sep-2020  msaitoh Add [-]eee and [-]vlan-hwfilter.
 1.120 23-Sep-2020  roy ifconfig: teach carrier test about ifi_link_state from SIOCGIFDATA

Because not all interfaces support media.
 1.119 08-Jul-2019  msaitoh Add "ifconfig [-]vlan-hwtagging" to enable/disable VLAN hardware tagging
offload function. It's useful to see Ethernet frame's VLAN tag by
disabling with "ifconfig fooX -vlan-hwtagging" and "tcpdump -e -i fooX".
 1.118 04-Jul-2019  wiz Formatting nit.
 1.117 04-Jul-2019  ozaki-r Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ
 1.116 15-Nov-2018  ozaki-r Fix the format of ifconfig linkstr; it takes an argument
 1.115 31-Jul-2018  sevan Remove ISO & XNS references which are now long gone.
 1.114 16-Feb-2017  wiz branches: 1.114.10; 1.114.12;
New sentence, new line.
Remove superfluous Oc and merge line to make it less likely to happen again.
Fix typo.
 1.113 16-Feb-2017  knakahara add man for l2tp(4).
 1.112 18-Jan-2017  abhinav Fix typo: s/forwared/forwarded
Also remove full stop from the date.
 1.111 11-Sep-2016  sevan branches: 1.111.2;
Replace contractions & abbreviation.
 1.110 07-Jan-2016  roy branches: 1.110.2;
-W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
 1.109 20-Oct-2014  roy Remove the ability for userland to toggle IN6_IFF_TENTATIVE.
Preserve IN6_IFF_TENTATIVE when updating address flags.
 1.108 15-Sep-2014  ozaki-r Write about -vlanif in ifconfig.8

PR 49114
 1.107 11-Sep-2014  roy Remove rtsol(8) and rtsold(8) as their functionality is in dhcpcd(8).
Remove rtsol(8) from rc.d/network.
Add -w seconds command to ifconfig to wait for N seconds for until DAD
has finished on all addresses.
Use ifconfig -w in rc.d/network instead of a forced sleep.

As discussed on tech-net@
 1.106 07-Jan-2014  degroote branches: 1.106.4;
Before scanning, check if the card is up. If it is not the case, exit
with some useful error message. Add some note about this fact in the man
page too.
 1.105 09-Nov-2013  kefren Bring tunnel src_addr and dst_addr on the same line
 1.104 28-Jan-2012  mbalmer branches: 1.104.2; 1.104.6;
When ifconfig is invoked without any arguments, display the list of
all network interfaces (equivalent to ifconfig -a), instead of displaying
the usage. (This is consistent with the behaviour on FreeBSD and OpenBSD.)
 1.103 31-May-2011  riastradh branches: 1.103.4;
Fix typo: `symbolically' takes three l's, not two.
 1.102 15-Nov-2010  pooka Implement ifconfig linkstr as proposed on tech-net.
 1.101 14-Sep-2009  degroote Import pfsync support from OpenBSD 4.2

Pfsync interface exposes change in the pf(4) over a pseudo-interface, and can
be used to synchronise different pf.

This work was part of my 2009 GSoC

No objection on tech-net@
 1.100 07-Aug-2009  dyoung Describe the -N flag.
 1.99 29-Jul-2009  hubertf Add "MAC" keyword to the corresponding example.
 1.98 02-Jul-2009  dyoung Use the keyword 'MAC' so that people looking for a way to change
their MAC address can find the example.
 1.97 02-Jul-2009  dyoung Deprecate wiconfig's -r, -g, -m options. Note that equivalent
options are available in ifconfig(8).
 1.96 08-Apr-2009  joerg Remove physical markup. Remove incorrect keep, .Bk is not callable, but
used as such. It doesn't seem to serve any purpose at the point either.
 1.95 27-Mar-2009  reed Point to ifmedia(4) more. And refer to -m flag to (for media).
 1.94 30-Sep-2008  wiz branches: 1.94.2; 1.94.4; 1.94.8;
Bump date for previous. Remove trailing whitespace.
New sentence, new line. Capitalize Ethernet.
 1.93 29-Sep-2008  dyoung Do not mention the 'ns' address family any longer, since that
support was removed quite a while ago.

Mention the 'link' address family. Describe the 'active' keyword.
Add examples for adding and activating a link-layer address.
 1.92 16-Dec-2007  degroote branches: 1.92.2; 1.92.4;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.91 05-Jun-2007  mishka branches: 1.91.4; 1.91.6;
Our VLAN implementation (as it correctly expected) is not allowed
to modify the whole VLAN tags, but it is permitted to change 12-bit
VLAN identificators only. Reflect this fact on the appropriate man
pages.

Antti Kantee and Mihai Chelaru from #netbsd-code were helpful in
better understanding of VLAN stuff. Thank you!
 1.90 09-Jan-2007  dyoung Let us adjust the 802.11 fragmentation threshold with ifconfig ath0
frag 256, for example.
 1.89 23-Dec-2006  wiz Punctuation nit, sort SEE ALSO.
 1.88 03-Dec-2006  wiz Remove a troff command that added some empty lines to the man(1) output.
 1.87 23-Nov-2006  yamt implement ipv6 TSO.
partly from Matthias Scheler. tested by him.
 1.86 16-Sep-2006  hubertf Fix typo, noted by Nino Dehne <ndehne@gmail.com>
 1.85 31-Aug-2006  dyoung Add a mode to gre(4) that sends GRE tunnel packets in UDP datagrams.
Fix MOBILE encapsulation. Add many debugging printfs (mainly
concerning UDP mode). Clean up the gre(4) code a bit. Add the
capability to setup UDP tunnels to ifconfig. Update documentation.

In UDP mode, gre(4) puts a GRE header onto transmitted packets,
and hands them to a UDP socket for transmission. That is, the
encapsulation looks like this: IP+UDP+GRE+encapsulated packet.

There are two ways to set up a UDP tunnel. One way is to tell the
source and destination IP+port to gre(4), and let gre(4) create
the socket. The other way to create a UDP tunnel is for userland
to "delegate" a UDP socket to the kernel.
 1.84 30-Jun-2006  drochner fix an Xref
 1.83 18-May-2006  liamjfoy Integrate Common Address Redundancy Procotol (CARP) from OpenBSD

'pseudo-device carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
 1.82 06-May-2006  wiz Remove trailing whitespace.
 1.81 29-Apr-2006  rpaulo Add two new options from FreeBSD:
hidessid | -hidessid: SSID broadcast control
apbridge | -apbridge: how to pass packets between wifi clients
 1.80 11-Sep-2005  wiz Argument is address_family, not "address family". From YOMURA Masanori in private mail.
 1.79 11-Aug-2005  rpaulo Explained the '-h' option.
 1.78 02-May-2005  yamt bump date for the previous.
 1.77 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.76 18-Mar-2005  wiz Link to vlan(4) too, suggested by yamt.
 1.75 18-Mar-2005  wiz Bump date for agr; add agr(4) to SEE ALSO.
 1.74 18-Mar-2005  yamt add agr(4), a pseudo network device driver for link aggregation.
 1.73 06-Mar-2005  matt branches: 1.73.2;
Add ifconfig support for TCP Segment Offload
 1.72 01-Mar-2004  wiz Add an article.
 1.71 01-Mar-2004  perry Change "nwid" to "ssid", list "nwid" as a synonym for "ssid", and
clean up the ssid explanation a bit (including mentioning that if you
want to use a hex ssid, you precede it with a 0x, which really needed
documenting.)
 1.70 29-Feb-2004  wiz Drop trailing whitespace (hi perry! :) ).
 1.69 29-Feb-2004  perry update man page date. (hi wiz!)
 1.68 29-Feb-2004  perry document that if you are using a hex wep key, you need to put 0x in
front of it.
 1.67 29-Feb-2004  perry document "mode" -- taken from FreeBSD
 1.66 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.65 16-Apr-2003  wiz Combine no-argument options in SYNOPSIS.
 1.64 12-Apr-2003  perry Document the -v and -z flags.
 1.63 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.62 30-Sep-2002  grant New sentence, new line.
 1.61 30-Sep-2002  onoe Fix the option name 'channel' to 'chan' to be consistent with the source.
Add documents for '-chan' to unset the desired channel to associate.
 1.60 25-Sep-2002  wiz Grammar fixes. Bump Dd for recent additions.
 1.59 22-Sep-2002  thorpej New commands:
* bssid xx:xx:xx:xx:xx:xx -- set the desired BSSID of an 802.11
interface.
* -bssid -- unset the desired BSSID of an 802.11 interface, so
the interface will choose automatically (default).
* channel x -- set the channel (radio frequency) of an 802.11 interface.

Current BSSID and channel are now reported in the 802.11 status
display, if supported by the interface.

Above changes from David Young <dyoung@ojctech.com>, with some slight
changes by me (use ethers(3) functions rather than hand-parsing/printing
the 802.11 address).

Document bssid/-bssid/channel, and clean up markup of parentheticals
in the manual page.
 1.58 01-Sep-2002  ross xref ifconfig.if(5)
 1.57 06-Aug-2002  jwise Fix mandoc glitch in description of `eui64' command.
 1.56 14-Jun-2002  itojun support "eui64" option (grab interface ID from link-local addr).
from: ww@styx.org
 1.55 09-Jun-2002  itojun now "ifconfig tunnel" is usable for gre too, change wording slightly
 1.54 16-Nov-2001  wiz Whitespace nits
 1.53 17-Sep-2001  thorpej Add tcp4csum-rx and udp4csum-rx commands for interfaces that only
support TCP/UDP checksums on the in-bound direction.
 1.52 21-Jun-2001  onoe Add support of persistent key of IEEE 802.11 wireless LAN card.
Currently, only Aironet ("an") driver/card can be used.
nwkey persist (IEEE 802.11 devices only) Enable WEP encryption for IEEE
802.11-based wireless network interfaces with the persis-
tent key written in the network card.
nwkey persist:key
(IEEE 802.11 devices only) Write the key to the persis-
tent memory of the network card, and enable WEP encryp-
tion for IEEE 802.11-based wireless network interfaces
with the key.
 1.51 05-Jun-2001  wiz Drop arguments of .Os.
 1.50 02-Jun-2001  thorpej Implement support for IP/TCP/UDP checksum offloading provided by
network interfaces. This works by pre-computing the pseudo-header
checksum and caching it, delaying the actual checksum to ip_output()
if the hardware cannot perform the sum for us. In-bound checksums
can either be fully-checked by hardware, or summed up for final
verification by software. This method was modeled after how this
is done in FreeBSD, although the code is significantly different in
most places.

We don't delay checksums for IPv6/TCP, but we do take advantage of the
cached pseudo-header checksum.

Note: hardware-assisted checksumming defaults to "off". It is
enabled with ifconfig(8). See the manual page for details.

Implement hardware-assisted checksumming on the DP83820 Gigabit Ethernet,
3c90xB/3c90xC 10/100 Ethernet, and Alteon Tigon/Tigon2 Gigabit Ethernet.
 1.49 28-Apr-2001  itojun make -A a default. present MAC adderss on all ifconfig operations.
 1.48 27-Apr-2001  itojun allow ifconfig to take "deprecated" and "-deprecated" for IPv6. sync with kame

sync usage() with reality. take "up" and "down" outside of "[af ...],
as "up" and "down" are independent from interface address configuration.
 1.47 17-Jan-2001  itojun support "prefixlen n" for IPv4 too.
 1.46 12-Dec-2000  onoe powersavesleep requires argument
 1.45 12-Dec-2000  thorpej Add powersave, -powersave, and powersavesleep to manipulate 802.11
power management parameters.
 1.44 18-Oct-2000  kleink Don't make references to _10Mb/s_ Ethernet where not appropriate; from
Christian Weisgerber.
 1.43 27-Sep-2000  thorpej Add vlan(4) support. From Andy Doran <ad@netbsd.org>.
 1.42 13-Aug-2000  wiz add two letters in strategically important places, and replace one
ifconfig by .Nm
 1.41 21-Jul-2000  onoe also note that the WaveLAN/IEEE Gold cards accept the 104 bits key.
pointed out by jhawk.
XXX this doesn't match to wiconfig(8), which is probably wrong.
 1.40 21-Jul-2000  onoe Clarify the restrictions in length for argument of the nwid and nwkey.
 1.39 21-Jul-2000  onoe Add nwkey and -nwkey keywords, to enable/disable WEP,
and to set WEP encryption key for IEEE802.11 wireless network interfaces.
 1.38 20-Jul-2000  thorpej Add a -C flag, to list all available network interface cloners.
 1.37 06-Jul-2000  onoe hexadecimal digits for nwid.
 1.36 03-Jul-2000  enami - Remove description about trailers/-trailers since they are no longer
a meaningful option.
- Don't captialize the word address or interface when it refers an arugment.
- Use .Ar macro for dest_address since it is not a keyword.
 1.35 03-Jul-2000  enami Sort the SEE ALSO list first by section and kill the comma at the
end of the list.
 1.34 02-Jul-2000  thorpej Add `create' and `destroy' commands.
 1.33 30-Jun-2000  thorpej - Add `tunnel' and `deletetunnel' commands, which issue the ioctls
that gifconfig(8) would issue to configure tunnel endpoints. This
allows IP tunnel interfaces (`gif' right now, and `gre' later) to
be configured with ifconfig(8), and via /etc/ifconfig.<interface>.
Partially taken from similar changes in OpenBSD.
- Const poison the command functions a bit. We really need to clean
up the command function interface.
 1.32 01-Mar-2000  enami branches: 1.32.4;
Fix typo.
 1.31 31-Jan-2000  itojun note that ifconfig delete does not work for IPv6
this is intentional - IPv6 assumes multiple addresses on an interface,
and it is not very safe to "delete" arbitrary one. -alias with
explicit IPv6 address works fine.
 1.30 31-Jan-2000  itojun add "nwid" directive.
XXX there are too many flags that are not listed in usage().
what should we do?
 1.29 12-Jan-2000  joda implement netmask slash notation for IP and IPv6 addresses
 1.28 09-Dec-1999  itojun add reference to "inet6" family.
document -alias.
 1.27 03-Jul-1999  sommerfeld branches: 1.27.4;
Add a new -s option to make it easier to test the link-level status
(i.e., 10baseT carrier/no carrier) of an interface from scripts

ifconfig -s <interface> will exit with a false status if the interface
reports its unconnected.

-s also works in conjunction with -l and -a, filtering out interfaces
which are reporting down.

Also, add -b (which shows only broadcast interfaces with -l and -a).

I find these options useful in network autoconfig scripts for mobile
systems.
 1.26 02-Jul-1999  itojun write up IPv6 operations (prefixlen and others)
 1.25 01-Jul-1999  itojun make ifconfig IPv6-ready.
TODO: update manpage for new options.
 1.24 06-Sep-1998  christos Add support for displaying interface alias information. Based on PR/6109 by
Phil Nelson.
 1.23 09-Aug-1998  thorpej Cross-reference ifmedia(4).
 1.22 08-Aug-1998  thorpej Document "instance".
 1.21 11-Oct-1997  enami - Use .Nm "" instead of .Nm ifconfig in SYNOPSIS.
- Delete space at the end of line.
 1.20 10-Oct-1997  lukem all but the first .Nm in SYNOPSIS need to be spelt out. [bin/4256]
 1.19 15-Sep-1997  lukem * cleanup for WARNS=1
* deprecate register
* use .Nm correctly
 1.18 30-May-1997  lukem Add "mask" argument to description of "broadcast".
From Thorsten Frueauf <frueauf@ira.uka.de> in [misc/3657]
 1.17 21-Apr-1997  lukem Implemented two modifier flags for -a and -l: -d (only show "down" interfaces)
and -u (only show "up" interfaces)
 1.16 10-Apr-1997  is Add mtu n parameter. Part of code by Matthias Pfaller (PR 1648).
 1.15 10-Apr-1997  jeremy Fix typo in media selector example. (from frueauf@ira.uka.de)
Fixes half of PR#3470.
 1.14 03-Apr-1997  christos - netatalk additions
- KNF
- prototype fixes
- ifconfig -a now prints all the address family parameters for all configured
interfaces.
 1.13 27-Mar-1997  thorpej Add a "-l" flag, which lists available network interfaces, with no
additional information.
 1.12 17-Mar-1997  thorpej Add support for BSD/OS-style media selection:
- new "media" keyword specified media to select:
ifconfig de0 media utp
- new "mediaopt/-mediaopt" keywords for setting/clearing
media options (such as full-duplex)
- new "-m" flag to display all supported media types for
a given interface.
Also, some generial cleanup of argument parsing while I was there.
Manual page updates from Jeremy Cooper <jeremy@netbsd.org>.
 1.11 04-Jan-1996  pk Merge with lite-2.
 1.10 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.9 23-Sep-1994  mycroft Merge with 4.4-Lite version.
 1.8 22-Jan-1994  cgd fix a botch
 1.7 14-Jan-1994  jtc Fix spelling errors
 1.6 10-Dec-1993  cgd LLC -> LINK, documentation
 1.5 01-Aug-1993  mycroft Add RCS indentifiers.
 1.4 04-May-1993  deraadt Added another sunos-ism: ifconfig -a
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 04-Jan-1996  pk imported from 44lite2
 1.1.1.2 23-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.27.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.32.4.10 01-May-2001  he Pull up revision 1.49 (requested by itojun):
Make ``-A'' the default, so that IPv4 aliases are printed.
Always print mac address.
 1.32.4.9 31-Dec-2000  jhawk Pull up revision 1.43 (requested by bouyer):
Add support for 802.1Q virtual LANs.
 1.32.4.8 31-Dec-2000  jhawk Pull up revision 1.34, 1.38 (requested by bouyer):
Support cloning of network pseudo-interfaces.
 1.32.4.7 13-Aug-2000  wiz Pull up 1.41 -> 1.42 (approved by thorpej):
add two letters in strategically important places, and replace
one ifconfig by .Nm
 1.32.4.6 21-Jul-2000  onoe Pullup 802.11 stuff (approved by jhawk)
- clarify the restriction for nwid/nwkey, add supported hardwares.
basesrc/sbin/ifconfig/ifconfig.8 1.40-1.41
saresrc/share/man/man4/awi.4 1.9
saresrc/share/man/man4/wi.4 1.11
 1.32.4.5 21-Jul-2000  onoe Pullup 802.11 stuff (approved by jhawk)
- add support for nwkey to ifconfig
basesrc/sbin/ifconfig/ifconfig.c 1.88
basesrc/sbin/ifconfig/ifconfig.8 1.39
syssrc/sys/dev/ic/awi.c 1.26
syssrc/sys/dev/ic/awi_wep.c 1.3
syssrc/sys/dev/ic/awivar.h 1.12
syssrc/sys/dev/pcmcia/if_wi.c 1.26
syssrc/sys/net/if.c 1.69
syssrc/sys/net/if_ieee80211.h 1.5
 1.32.4.4 21-Jul-2000  onoe Pullups 802.11 stuff (approved by jhawk)
- allow non-string nwid settings
basesrc/sbin/ifconfig/ifconfig.c 1.82-1.86
basesrc/sbin/ifconfig/ifconfig.8 1.37
syssrc/sys/dev/ic/awi.c 1.21
syssrc/sys/dev/pcmcia/if_ray.c 1.21
syssrc/sys/dev/pcmcia/if_wi.c 1.23
syssrc/sys/dev/pcmcia/if_wivar.h 1.10
syssrc/sys/net/if_ieee80211.h 1.4
 1.32.4.3 03-Jul-2000  thorpej Pull up rev. 1.36:
- Remove description about trailers/-trailers since they are no longer
a meaningful option.
- Don't captialize the word address or interface when it refers an arugment.
- Use .Ar macro for dest_address since it is not a keyword.
 1.32.4.2 03-Jul-2000  thorpej Pull up rev. 1.35:
Sort the SEE ALSO list first by section and kill the comma at the
end of the list.
 1.32.4.1 30-Jun-2000  thorpej - Add `tunnel' and `deletetunnel' commands, which issue the ioctls
that gifconfig(8) would issue to configure tunnel endpoints. This
allows IP tunnel interfaces (`gif' right now, and `gre' later) to
be configured with ifconfig(8), and via /etc/ifconfig.<interface>.
Partially taken from similar changes in OpenBSD.
- Const poison the command functions a bit. We really need to clean
up the command function interface.

Rationale for pulling into netbsd-1-5 branch: While this looks like
a feature enhancement, it actually fixes a bug -- without this change
or a change in rc.d's network bring-up, it is not possible to configure
IP tunnels as a normal part of bringing up the network.
 1.73.2.1 24-Mar-2006  riz Pull up following revision(s) (requested by rpaulo in ticket #1219):
sbin/ifconfig/ifconfig.8: revision 1.79
Explained the '-h' option.
 1.91.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.91.4.1 09-Jan-2008  matt sync with HEAD
 1.92.4.1 05-Oct-2008  mjf Sync with HEAD.
 1.92.2.1 22-Feb-2008  keiichi imported Mobile IPv6 code developed by the SHISA project
(http://www.mobileip.jp/).
 1.94.8.1 21-Apr-2010  matt sync to netbsd-5
 1.94.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.94.2.2 29-Jul-2009  hubertf backout previous - wrong branch, thanks veego
 1.94.2.1 29-Jul-2009  hubertf Add "MAC" keyword to the corresponding example.
 1.103.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.103.4.1 17-Apr-2012  yamt sync with head
 1.104.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.104.2.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by ozaki-r in ticket #1156):
sbin/ifconfig/vlan.c: revision 1.14
sbin/ifconfig/ifconfig.8: revision 1.108
sys/net/if_vlan.c: revision 1.71
sys/net/if_vlan.c: revision 1.73
sys/net/if_vlan.c: revision 1.74
- PR#49114: Write about -vlanif in ifconfig.8.
Add -vlanif to the help message of ifconfig.
- PR#49196: Leave promiscuous mode when detaching a parent (ifconfig -vlanif)
We have to call ifpromisc(ifp, 0) for both a VLAN interface
and its parent when they are in promiscuous mode.
- PR#49197: Delete link local addresses of a vlan interface when detaching its
parent.
- PR#49112: Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig
 1.106.4.2 27-Oct-2014  martin Pull up following revision(s) (requested by roy in ticket #160):
sbin/ifconfig/af_inet6.c: revision 1.30
sbin/ifconfig/ifconfig.8: revision 1.109
sys/netinet6/in6.c: revision 1.177
Remove the ability for userland to toggle IN6_IFF_TENTATIVE.
Preserve IN6_IFF_TENTATIVE when updating address flags.
 1.106.4.1 22-Sep-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #108):
sbin/ifconfig/vlan.c: revision 1.14
sbin/ifconfig/ifconfig.8: revision 1.108
sys/net/if_vlan.c: revision 1.71-1.74

Document -vlanif in ifconfig.8 and in usage measseg (PR 49114).
Leave promiscuous mode when detaching a parent (PR 49196) and
delete link local addresses (49197).
Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig
(PR 49112).
Call if_input of vlan interface itself, not parent one.
This allows bridging vlan interfaces again.
 1.110.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.111.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.114.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.114.12.1 10-Jun-2019  christos Sync with HEAD
 1.114.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.114.10.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.124.2.3 21-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #902):

sbin/ifconfig/carp.c: revision 1.15
sbin/ifconfig/ifconfig.8: revision 1.125
tests/net/carp/t_basic.sh: revision 1.9
sys/netinet/ip_carp.c: revision 1.118
sys/netinet/ip_carp.c: revision 1.119

Fix parser for carp state.

The state values are uppercase words INIT, BACKUP and MASTER.

Use backing device to send advertisements. Otherwise the packets originate
from the virtual MAC address, which confuses switches.

Select virtual address as sender if backing interface is anonymous.

Use correct scope for IPv6.

Don't expect the net/carp/t_basic/carp_handover_ipv6_halt_nocarpdevip
and carp_handover_ipv6_ifdown_nocarpdevip test cases to fail. At
least on the TNF i386 and amd64 testbeds, they pass more often than
not since the commit of src/sys/netinet/ip_carp.c 1.119 by mlelstv on
2023.04.07.06.44.08.
 1.124.2.2 24-Aug-2024  martin Pull up following revision(s) (requested by ozaki-r in ticket #811):

tests/net/if_shmif/t_shmif.sh: revision 1.1
sbin/ifconfig/ifconfig.c: revision 1.251
sbin/ifconfig/ifconfig.8: revision 1.130
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.85
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.86
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.87
etc/mtree/NetBSD.dist.tests: revision 1.206
distrib/sets/lists/tests/mi: revision 1.1333
tests/net/if_shmif/Makefile: revision 1.1
tests/net/Makefile: revision 1.42

shmif: change behaviors about link states

- Change the link state to UP on ifconfig linkstr
- This behavior emulates physical devices
- Change the link state to UNKNOWN on ifconfig -linkstr just in case
- Reject sending/receiving packets if the link state is DOWN
- Permit to send/receive packets on UNKNOWN, which is required
to unbreak some ATF tests written in C

shmif: support media

It enables to link-down shmif by ifconfig media none and link-up
again by media auto.

ifconfig: show link state on -v

We could guess it through "media" or "status" output, however, we
sometimes want to know it directly for debugging or testing.

It is shown only if the -v option is specified.
tests: add tests for shmif

The test file is placed under tests/net, not tests/rump/rumpnet,
to leverage utility functions provided for tests in there.
shmem(4): Fix typo in comment: AFT -> ATF.

Also fix grammar (if I understood correctly what this meant: rump
servers written in C, rather than set up via shell scripts around
rump_server invoking ifconfig).

No functional change intended.
 1.124.2.1 18-Apr-2024  martin Pull up following revision(s) (requested by andvar in ticket #660):

sbin/ifconfig/ifconfig.8: revision 1.126
sbin/ifconfig/ifconfig.8: revision 1.127
sbin/ifconfig/ifconfig.8: revision 1.128
sbin/ifconfig/ifconfig.8: revision 1.129

Added documents about parameters related to lagg(4)
PR misc/58125

Correct a very minor typo (s/id/is/)

ifconfig(8): move laggportpri next to laggport

Update the date of the documentation to reflect recent changes.
 1.129.2.1 02-Aug-2025  perseant Sync with HEAD
 1.251 20-Aug-2024  ozaki-r ifconfig: show link state on -v

We could guess it through "media" or "status" output, however, we
sometimes want to know it directly for debugging or testing.

It is shown only if the -v option is specified.
 1.250 03-Jan-2024  andvar branches: 1.250.2;
s/addreseses/addresses/ in comments (and one missing whitespace).
 1.249 25-Nov-2022  knakahara branches: 1.249.2;
ifconfig(8) support unnumbered flag.
 1.248 14-Oct-2020  roy ifconfig: go back to using direct ioctls rather than data from getifaddrs

AF_LINK may not be the first address returned for the interface.
Technically, it *might* not even exist on the interface even though
other families do.
This is likely a driver bug if this really is the case though.

As such it's just easier to use direct ioctls rather than thump around
getifaddrs results. As it stands, the code makes a lot of getifaddrs
calls anyway, so an extra ioctl or two won't break the bank.
 1.247 28-Sep-2020  roy ifconfig: Just look at if_data->ifi_link_state for carrier

It should be the sole source of truth.
if_data is also carried in ifa_data from getifaddrs(3) which saves
more ioctl calls.
 1.246 26-Sep-2020  roy ifconfig: We already have struct if_data in ifa_data.

So let's not bother with an ioctl we don't need.
 1.245 23-Sep-2020  roy ifconfig: test cases want LINK_STATE_UNKNOWN to be treated as up.
 1.244 23-Sep-2020  roy ifconfig: teach carrier test about ifi_link_state from SIOCGIFDATA

Because not all interfaces support media.
 1.243 22-Sep-2020  roy ifconfig: Report link state even if media is not supported

For AF_LINK addrs from getifaddrs(2), ifa_data is struct if_data.
This in turn holds ifi_link_state which we can use to report
link status if the interface does not support media where it's normally
reported.

Based on OpenBSD.
 1.242 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.241 02-Jan-2020  ryo fix printing capabilities and enabled flags.

no need to skip a prefix "0x" of output of snprintb.
ifconfig expect the result of snprintb has "0x" prefix, but snprintb(3) specification has changed
so that if 0 is passed, it prints "0" instead of "0x0". (common/lib/libutil/snprintb.c r1.22)
 1.240 16-Aug-2019  msaitoh Whitespace fix.
 1.239 04-Jul-2019  ozaki-r Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ
 1.238 21-Dec-2018  msaitoh Add SIOCSETHERCAP. It's used to change ec_capenable.
 1.237 15-Nov-2018  ozaki-r ifconfig: add linkstr/-linkstr to the help message
 1.236 07-Jan-2016  roy branches: 1.236.14; 1.236.16;
-W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
 1.235 29-Jul-2015  ozaki-r Don't divide flags output

If there are many enabled flags, ifconfig divides flags output into
multiple formatted strings due to snprintb_m, e.g.,
wm0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX>wm0: flags=8b43<MULTICAST> mtu 1500

This behavior is probably unexpected. The change always outputs enabled
flags at once like this:
wm0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
 1.234 22-Apr-2015  roy Move the INET6 specific code for wait_dad_exec() into af_inet6
by using a new afswtch hook af_addr_tentative.
 1.233 12-Sep-2014  martin Initialize timespec "end" for the benefit of some gcc versions getting
"may be used uninitialized" warnings wrong.
 1.232 11-Sep-2014  roy Remove rtsol(8) and rtsold(8) as their functionality is in dhcpcd(8).
Remove rtsol(8) from rc.d/network.
Add -w seconds command to ifconfig to wait for N seconds for until DAD
has finished on all addresses.
Use ifconfig -w in rc.d/network instead of a forced sleep.

As discussed on tech-net@
 1.231 19-Oct-2013  christos use the new scopeid functions
 1.230 17-Jul-2013  christos Allow -v to be used with other commands (list scan for example) as documented.
 1.229 07-Feb-2013  apb Abort on error from prop_dictionary_augment.
 1.228 01-Nov-2012  pgoyette Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users
 1.227 28-Jan-2012  mbalmer branches: 1.227.6;
When ifconfig is invoked without any arguments, display the list of
all network interfaces (equivalent to ifconfig -a), instead of displaying
the usage. (This is consistent with the behaviour on FreeBSD and OpenBSD.)
 1.226 29-Aug-2011  joerg branches: 1.226.2;
Use __dead
 1.225 14-Dec-2010  pooka A few weeks ago when i added "linkstr" support I didn't know that
the string parser gives a proplib object which isn't a terminated
string. Fix that mistake now.
 1.224 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.223 15-Nov-2010  pooka Implement ifconfig linkstr as proposed on tech-net.
 1.222 05-Nov-2010  pooka adapt to new rumpclient_init() signature
 1.221 04-Nov-2010  pooka Update RUMP_ACTION to use the newstyle rump client.
 1.220 07-Aug-2009  dyoung Add option -N. -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
 1.219 26-May-2009  pooka Add compile mode which executes rump system calls. This is useful
when figuring out Where In The Kernel Is Carmen Sandiego's ioctl
for an ifconfig command line, since we can simply single-step into
the kernel.

Activated by "make RUMP_ACTION=1". No changes to normal case.
 1.218 21-Apr-2009  dyoung To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
 1.217 21-Apr-2009  dyoung Cosmetic: add some whitespace for my ease of reading.
 1.216 21-Apr-2009  dyoung There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
 1.215 04-Apr-2009  plunky Because the IFF_NOARP flag is a negative option it needs to be negated
when being applied from the "arp" option which itself is positive.

problem demonstrated by

# ifconfig tap3 create
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 arp
# ifconfig tap3
tap3: flags=8882<BROADCAST,NOARP,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 -arp
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 destroy
#
 1.214 18-Jan-2009  lukem branches: 1.214.2;
fix -Wsign-compare issues
 1.213 01-Aug-2008  dyoung branches: 1.213.2;
Extract common code. Create subroutine paddr_prefix_size().
 1.212 20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.211 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.210 15-Jul-2008  dyoung Make usage() static.
 1.209 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.208 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.207 03-Jun-2008  dyoung Remove one more struct afswtch.af_getprefix() remnant.
 1.206 03-Jun-2008  dyoung Remove remnants of struct afswtch.af_getprefix().
 1.205 19-May-2008  dyoung Fix two bugs:

1 Let us associate a keyword with either a signed or an unsigned
number. Associate the '-chan' keyword with an unsigned number.
This fixes the defect that crashed 'ifconfig wi0 -chan', reported
by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
address family was specified. iso_addr(3) does not report errors,
so it appears to interpret *everything* as an ISO address. This
is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
!INET6 kernel that deletes the first IPv4 address on lo0.
(Reported by Scott Ellis.)
 1.204 12-May-2008  dyoung Per discussion at
<http://mail-index.netbsd.org/tech-net/2008/04/08/msg000371.html>,
let us add, delete, and activate link-layer addresses with ifconfig:

# ifconfig sip0 link 02:00:00:00:00:01 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 [add address]
# ifconfig sip0 link 02:00:00:00:00:02 active [activate address]
# ifconfig sip0 link 02:00:00:00:00:01 delete [remove address]
 1.203 11-May-2008  dyoung Let the address family modules zero initialize their own ifreqs,
instead of zeroing them in commit_address().

Switch to in6_commit_address() from in6_getprefix() and in6_getaddr().

Temporarily add some debugging code to setia6eui64_impl().
 1.202 08-May-2008  dyoung Move IPv4/IPv6-specific code from commit_address() to in_commit_address()
and in6_commit_address(). Fixes the USE_INET6=no build.
 1.201 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.200 07-May-2008  dyoung Move IPv6 syntax to af_inet6.c from ifconfig.c. Move IFKW() macro
from ifconfig.c to parse.h for reuse.
 1.199 07-May-2008  dyoung Move ISO, AppleTalk, carp(4) syntax from ifconfig.c to af_iso.c,
af_atalk.c, carp.c, respectively.
 1.198 07-May-2008  dyoung Sprinkle 'static const' on keyword objects.
 1.197 07-May-2008  dyoung Move vlan(4) syntax from ifconfig.c into vlan.c.
 1.196 07-May-2008  dyoung Move tunnel syntax into tunnel.c. Move net80211 'list' command
syntax into ieee80211.c.
 1.195 07-May-2008  dyoung Move net80211 and agr(4) syntax out of ifconfig.c and into ieee80211.c
and agr.c, respectively.
 1.194 07-May-2008  dyoung Fix a bug that I introduced in rev 1.88, where the default IPv6
prefix length changed from 64 to 128. While I am here, allow an
address to be given with prefix length /0, but interpret it as
/128.
 1.193 06-May-2008  dyoung branches: 1.193.2;
Use the right key, "ifcaps" not "ifcap", in do_setifcaps(). assert()
that the object associated with that key is the right size.
 1.192 06-May-2008  dyoung Extract subroutine do_setifcaps() and fix the bug that uwe@ reported
in capabilities-setting.

Use prop_dictionary_util(3).

Rename the parser snpaoffset to parse_snpaoffset.
 1.191 06-May-2008  dyoung Fix syntax error in last.
 1.190 06-May-2008  dyoung Cosmetic: use return rc ? 0 : -1;

Make sure to release a prop_object_t that I am no longer using.
 1.189 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.188 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.187 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.186 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.185 21-Apr-2008  dyoung Change int to bool in a couple of places.
 1.184 15-Apr-2008  dyoung branches: 1.184.2;
Straggler from last: call fewer protocol family-specific initialization
routines from main(), since the protocol-family modules are taking
care of it.
 1.183 14-Apr-2008  dyoung Cosmetic: delete dead code.
 1.182 11-Apr-2008  dyoung Cosmetic: use NULL instead of 0 for pointers. Shorten staircase.
 1.181 16-Dec-2007  degroote branches: 1.181.2; 1.181.4;
Add support for the command list scan in ifconfig (this command permits to scan
access point in the neighbourhood).

Complete list of channel attributes and list of management information element
payload.

While here, use estrlcpy instead of strncpy.

From FreeBSD ifconfig and net80211
 1.180 09-Jan-2007  dyoung branches: 1.180.4; 1.180.6;
Let us adjust the 802.11 fragmentation threshold with ifconfig ath0
frag 256, for example.
 1.179 23-Nov-2006  yamt implement ipv6 TSO.
partly from Matthias Scheler. tested by him.
 1.178 13-Nov-2006  dyoung Add a source-address selection policy mechanism to the kernel.

Also, add ioctls SIOCGIFADDRPREF/SIOCSIFADDRPREF to get/set preference
numbers for addresses. Make ifconfig(8) set/display preference
numbers.

To activate source-address selection policies in your kernel, add
'options IPSELSRC' to your kernel configuration.

Miscellaneous changes in support of source-address selection:

1 Factor out some common code, producing rt_replace_ifa().

2 Abbreviate a for-loop with TAILQ_FOREACH().

3 Add the predicates on IPv4 addresses IN_LINKLOCAL() and
IN_PRIVATE(), that are true for link-local unicast
(169.254/16) and RFC1918 private addresses, respectively.
Add the predicate IN_ANY_LOCAL() that is true for link-local
unicast and multicast.

4 Add IPv4-specific interface attach/detach routines,
in_domifattach and in_domifdetach, which build #ifdef
IPSELSRC.

See in_getifa(9) for a more thorough description of source-address
selection policy.
 1.177 16-Oct-2006  christos - get rid of p_cfunc2
- add missing initializers
 1.176 26-Aug-2006  christos Programs that use efun.
 1.175 26-Aug-2006  matt Nuke a leftover XNS fragment.
 1.174 26-Aug-2006  matt Remove XNS support.
 1.173 13-Jul-2006  martin Trying the old "ifconfig <name> x.x.x.x down" issue again:
if the kernel does not set the interface up after we set an address,
do it explicitly, unless we (previously) set it down on user request.

This will allow the network drivers to be "fixed" while keeping visible
behaviour the same. Part of fixing PR 30694.
 1.172 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.171 18-May-2006  liamjfoy Integrate Common Address Redundancy Procotol (CARP) from OpenBSD

'pseudo-device carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
 1.170 29-Apr-2006  rpaulo Add two new options from FreeBSD:
hidessid | -hidessid: SSID broadcast control
apbridge | -apbridge: how to pass packets between wifi clients
 1.169 11-Aug-2005  rpaulo Added a new ifconfig flag, -h, allowing, in conjunction with -v, the display
of interface I/O bytes in human-format.

Reviewed by Christos Zoulas and Jason Thorpe.
 1.168 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.167 20-Mar-2005  thorpej IFFBITS and IFCAPBITS are now defined in <net/if.h>
 1.166 20-Mar-2005  thorpej Split the IPv4 support into its own file.
 1.165 20-Mar-2005  thorpej Move a comment.
 1.164 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.163 20-Mar-2005  thorpej Split OSI support off into its own file.
 1.162 19-Mar-2005  thorpej Split XNS support into its own file.
 1.161 19-Mar-2005  thorpej Split off AppleTalk support into its own file.
 1.160 19-Mar-2005  thorpej const'ify afswtch
 1.159 19-Mar-2005  thorpej Split off 802.11 interface handling into its own file.
 1.158 19-Mar-2005  thorpej Don't hare-code inet/inet6 in tunnel_status(), lookup the address family
name instead.
 1.157 19-Mar-2005  thorpej Split tunnel support into its own file.
 1.156 19-Mar-2005  thorpej Move extern decls to extern.h
 1.155 19-Mar-2005  thorpej Split VLAN configuration bits out into a separate file.
 1.154 18-Mar-2005  yamt update usage() for agr(4). pointed by Thomas Klausner.
 1.153 18-Mar-2005  yamt add agr(4), a pseudo network device driver for link aggregation.
 1.152 06-Mar-2005  matt branches: 1.152.2;
Add ifconfig support for TCP Segment Offload
 1.151 06-Feb-2005  perry remove obsolete "register" declarations.
 1.150 20-Jan-2005  xtraeme Fix the cast for the getnameinfo() call in the status() function, which
should be "const struct" not "struct" for sockaddr.

WARNS=3
 1.149 20-Dec-2004  dyoung ifconfig -v prints 802.11 statistics. ifconfig -v prints and zeroes
802.11 statistics.
 1.148 16-Nov-2004  itojun NI_WITHSCOPEID was not picked up by IETF standardization process.
 1.147 11-Nov-2004  dsl Functions for converting media types to/from text are now in libutil.
 1.146 28-Oct-2004  dsl More isdigit() calls that need (unsigned char) cast
 1.145 11-Oct-2004  dsl De __P
 1.144 11-Oct-2004  dsl Remove all the caddr_t - mainly casts of the 3rd arg to ioctl()
 1.143 27-Jul-2004  yamt err -> errx where appropriate.
 1.142 06-Jul-2004  mycroft The change in revision 1.38 (in 1997!) was wrong. If we don't want the kernel
to automatically bring up interfaces, then we should move that code into
ifconfig(8) and out of the kernel, not cycle the interface up and down. Fixes
PR 9400 -- ifconfig(8) was not working as documented.
 1.141 01-Mar-2004  perry branches: 1.141.4;
Very minimal changes to make "ssid" and "nwid" aliases, and make the
ssid print out as "ssid", not "nwid".
XXX Really, someone should go through and change around all the
variable names etc. to ssid, but not today.
 1.140 27-Feb-2004  itojun check strlcpy error. idea from Ryan McBride
 1.139 13-Oct-2003  dyoung Add 'mode' option to change PHY media for 802.11 devices. Also,
display PHY mode. E.g., run an 802.11a (5GHz, 54Mbps max) access
point:

> ifconfig ath0 nwid my_access_point mode 11a mediaopt hostap
> ifconfig -m ath0
ath0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
nwid my_access_point
powersave off
bssid 00:05:5d:84:cc:6e chan 3
address: 00:05:5d:84:cc:6e
media: IEEE802.11 autoselect mode 11a hostap
status: active
supported IEEE802.11 media:
media autoselect
media autoselect mediaopt adhoc
media autoselect mediaopt hostap
media autoselect mediaopt monitor
media autoselect mode 11a
media autoselect mode 11a mediaopt adhoc
media autoselect mode 11a mediaopt hostap
media autoselect mode 11a mediaopt monitor
*snip snip*
 1.138 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.137 11-Jun-2003  christos PR/21860: Robert Elz: ifconfig doesn't allow addr/N notation for INET6
 1.136 17-May-2003  itojun use strlcpy
 1.135 17-May-2003  lukem Change -b from skipping POINTTOPOINT|LOOPBACK to skipping ! BROADCAST.
Fixes my [bin/21604]
 1.134 12-Apr-2003  perry Add an option (-z) like -v except that it clears the input/output
stats after printing them.
(Basically this just calls SIOCZIFDATA instead of SIOCGIFDATA).
Submitted by Jean-Edouard BABIN in PR bin/21078
However, he suggested using -c, and cgd (reasonably) noted that -z for
"zero" was probably more reasonable.
I've also changed the code very slightly.
 1.133 30-Sep-2002  onoe Hide bssid/chan for 802.11 if not specified nor not associated.
Allow "-chan" to allow any channel to associate, it doesn't affect
create channel for IBSS/AP mode.
 1.132 23-Sep-2002  thorpej Add missing newline.
 1.131 22-Sep-2002  thorpej New commands:
* bssid xx:xx:xx:xx:xx:xx -- set the desired BSSID of an 802.11
interface.
* -bssid -- unset the desired BSSID of an 802.11 interface, so
the interface will choose automatically (default).
* channel x -- set the channel (radio frequency) of an 802.11 interface.

Current BSSID and channel are now reported in the 802.11 status
display, if supported by the interface.

Above changes from David Young <dyoung@ojctech.com>, with some slight
changes by me (use ethers(3) functions rather than hand-parsing/printing
the 802.11 address).

Document bssid/-bssid/channel, and clean up markup of parentheticals
in the manual page.
 1.130 20-Sep-2002  christos use snprintb()
 1.129 20-Jul-2002  grant sweep of errx/warnx, remove unnecessary trailing \n
 1.128 14-Jun-2002  itojun grab eui64 only from the same interface.
 1.127 14-Jun-2002  itojun support "eui64" option (grab interface ID from link-local addr).
from: ww@styx.org
 1.126 14-Jun-2002  itojun init variable before strtoul
 1.125 14-Jun-2002  itojun metric and mtu are u_long, not int.
 1.124 23-May-2002  matt Add support to print interface counters (via SIOCGIFDATA) when the [new]
option -v is provided.
 1.123 06-May-2002  thorpej Don't bother testing if a u_short is > 0xffff -- that test is always false.
 1.122 25-Apr-2002  itojun use in_aliasreq for inet address manipulation, not ifaliasreq. they have
different alignment constraint. [tests on 64bit arch wanted]
 1.121 02-Nov-2001  lukem fix many -Wshadow warnings
 1.120 24-Oct-2001  atatat Clean up the code a bit so that the ioctl() return value is always
compared to -1 (instead of <0 or !=0) and always to call err() with
EXIT_FAILURE instead of sometimes using 1.
 1.119 06-Oct-2001  bjh21 Use getnameinfo() to format AF_LINK addresses again.
 1.118 05-Oct-2001  bjh21 Revert last change. getnameinfo() AF_LINK support is going away until I can
make it lint-clean.
 1.117 04-Oct-2001  bjh21 Use getnameinfo() to format AF_LINK addresses rather than doing it ourselves.
 1.116 26-Sep-2001  itojun remove duplicated line in cmds[].
 1.115 17-Sep-2001  thorpej Add tcp4csum-rx and udp4csum-rx commands for interfaces that only
support TCP/UDP checksums on the in-bound direction.
 1.114 19-Aug-2001  itojun snprintf return value audit. from deraadt
 1.113 09-Aug-2001  david Correct style of a comment, and bad else {} scoping from my previous
commit.

Thanks to enami tsugutomo for pointing both out.
 1.112 08-Aug-2001  david Cause multiple uses of alias, -alias, and delete to produce an error,
and exit.

Previously, combinations would produce unintended results, such as
deleting the primary IP on an interface, instead of deleting an specified
alias.
 1.111 31-Jul-2001  itojun embed scopeid on scoped ipv6 address. sync with kame
 1.110 25-Jul-2001  itojun do not go over the end of memory region we are supposed to touch,
overrun on "prefixlen" operation. there's no SEGV possibility.
 1.109 21-Jun-2001  onoe Add support of persistent key of IEEE 802.11 wireless LAN card.
Currently, only Aironet ("an") driver/card can be used.
nwkey persist (IEEE 802.11 devices only) Enable WEP encryption for IEEE
802.11-based wireless network interfaces with the persis-
tent key written in the network card.
nwkey persist:key
(IEEE 802.11 devices only) Write the key to the persis-
tent memory of the network card, and enable WEP encryp-
tion for IEEE 802.11-based wireless network interfaces
with the key.
 1.108 02-Jun-2001  thorpej Implement support for IP/TCP/UDP checksum offloading provided by
network interfaces. This works by pre-computing the pseudo-header
checksum and caching it, delaying the actual checksum to ip_output()
if the hardware cannot perform the sum for us. In-bound checksums
can either be fully-checked by hardware, or summed up for final
verification by software. This method was modeled after how this
is done in FreeBSD, although the code is significantly different in
most places.

We don't delay checksums for IPv6/TCP, but we do take advantage of the
cached pseudo-header checksum.

Note: hardware-assisted checksumming defaults to "off". It is
enabled with ifconfig(8). See the manual page for details.

Implement hardware-assisted checksumming on the DP83820 Gigabit Ethernet,
3c90xB/3c90xC 10/100 Ethernet, and Alteon Tigon/Tigon2 Gigabit Ethernet.
 1.107 28-Apr-2001  itojun make -A a default. present MAC adderss on all ifconfig operations.
 1.106 28-Apr-2001  itojun assume the presense of getifaddrs(3).
 1.105 27-Apr-2001  itojun sync usage() more to the reality. document alias/-alias.
 1.104 27-Apr-2001  itojun allow ifconfig to take "deprecated" and "-deprecated" for IPv6. sync with kame

sync usage() with reality. take "up" and "down" outside of "[af ...],
as "up" and "down" are independent from interface address configuration.
 1.103 01-Mar-2001  itojun whitespace at EOL
 1.102 01-Mar-2001  itojun on "tunnel" subcommand, use specified address family.
 1.101 23-Feb-2001  christos PR/12275:Kimmo Suominen: show -C in usage
 1.100 20-Feb-2001  itojun add SIOC[SG]LIFPHYADDR ioctl. greatly simplify tunnel address settings.
sync with kame. old ioctls are supplied but not recommended for new code.
 1.99 19-Feb-2001  cgd convert to use getprogname()
 1.98 04-Feb-2001  christos fix nested externs
 1.97 24-Jan-2001  garbled Fix the usage string so it displays the -b and s options to ifconfig -l
 1.96 17-Jan-2001  itojun unbroken slash notation (10.0.0.0/8) for IPv4.
 1.95 17-Jan-2001  itojun support "prefixlen n" for IPv4 too.
 1.94 08-Jan-2001  itojun uninitialized pointer. PR 11702
 1.93 12-Dec-2000  onoe Add powersave/powersavesleep into usage.
Fold usage output (still 14 lines...)
 1.92 12-Dec-2000  thorpej Add powersave, -powersave, and powersavesleep to manipulate 802.11
power management parameters.
 1.91 07-Nov-2000  itojun show IPv6 interface address status "deprecated" (preferred lifetime = 0).
RFC2462. sync with kame.
 1.90 02-Oct-2000  thorpej In tunnel_status(), if we have an IPv6 kernel, but a driver doesn't
support IPv6 tunnel endpoint addresses, fall back on the sockaddr
version of the ioctls.
 1.89 27-Sep-2000  thorpej Add vlan(4) support. From Andy Doran <ad@netbsd.org>.
 1.88 21-Jul-2000  onoe Add nwkey and -nwkey keywords, to enable/disable WEP,
and to set WEP encryption key for IEEE802.11 wireless network interfaces.
 1.87 20-Jul-2000  thorpej Add a -C flag, to list all available network interface cloners.
 1.86 19-Jul-2000  enami - Fix off-by-one error in previous.
- Fix a typo of ioctl name in warning message.
 1.85 19-Jul-2000  onoe check the length of nwid argument before copy to avoid SEGV.
pointed out by enami-san
 1.84 06-Jul-2000  onoe cast u_char for ctype (nwid stuff) to fix possible overrun problems.
 1.83 06-Jul-2000  onoe warn instead of print 802.11 nwid with bad length field.
 1.82 05-Jul-2000  onoe change the argument of SIOCS80211NWID and SIOCG80211NWID ioctls from
u_int8_t array to struct ieee80211_nwid to prepend length field.
The length field is necessary because IEEE 802.11 spec doesn't prohibit
even '\0' for SSID.
Though the name and the value of SIOC... macro is unchanged, this change
breaks binary compatibility. The only affected userland program on the
tree is ifconfig(8).
As Jason suggested on tech-net, it is better than live with problems
since there are no releases for this ioctls yet.
 1.81 02-Jul-2000  thorpej Add `create' and `destroy' commands.
 1.80 30-Jun-2000  thorpej - Add `tunnel' and `deletetunnel' commands, which issue the ioctls
that gifconfig(8) would issue to configure tunnel endpoints. This
allows IP tunnel interfaces (`gif' right now, and `gre' later) to
be configured with ifconfig(8), and via /etc/ifconfig.<interface>.
Partially taken from similar changes in OpenBSD.
- Const poison the command functions a bit. We really need to clean
up the command function interface.
 1.79 20-Apr-2000  enami branches: 1.79.4;
Allocate flagreq on stack.
 1.78 13-Apr-2000  itojun use getifaddrs, not SIOCGIFCONF, to avoid alignment constraints.
TODO: maybe it's better to pass struct ifaddrs * to in{,6}_alias.
 1.77 13-Apr-2000  itojun clarify in_alias() and in_status().
in_status() handles the whole inet address family. in_alias() handles
printout for single address (for both the primary address or an alias).
it is more consistent with, for example, the way at_status() is used.
 1.76 03-Apr-2000  enami Explicitly pick up ''the first address'' to delete.
 1.75 20-Mar-2000  onoe Set flagreq.ifr_name before issueing SIOCGIFFLAGS for setifflags.
Withoug this change, flagreq was never initialized and ifconfig w/o addr
always failed with ENXIO.
 1.74 18-Mar-2000  castor Fix PR bin/9629. The global variable ifr was used to save interface
flags even though the media routines tweak it.
 1.73 06-Mar-2000  enami Remove unnecessary continue statement.
 1.72 06-Mar-2000  enami Remove now unnecessary assignment. It looks like 4.4lite merge left over.
 1.71 06-Mar-2000  enami Don't copy from destination to destination.
 1.70 06-Mar-2000  thorpej Per a discussion on gcc-bugs, port-alpha/9494 is not a compiler bug, but
rather a bug in the code (which is violating the C standard by casting
an unaligned pointer to a pointer with more strict alignment constraints).

Fix the code to not do such things. Fixes port-alpha/9494.
 1.69 01-Mar-2000  enami Salvage the better comment appeared in rev 1.51 but gone in 1.53.
 1.68 18-Feb-2000  itojun more fix to SIOCGIFCONF alignment.
 1.67 25-Jan-2000  mycroft Fix a buglet that caused media-specific options to *always* be printed, even if
they were not set.
 1.66 25-Jan-2000  thorpej Fix a logic buglet in status printing code.
 1.65 25-Jan-2000  thorpej - Print 802.11 status (i.e. network ID) after mtu, etc. but before
protcol addresses.
- When searching for status bits, use the currently selected media type,
not the currently active media type.
 1.64 25-Jan-2000  thorpej Update copyright.
 1.63 25-Jan-2000  thorpej Make display of media status information (e.g. carrier, etc.) table-driven
and easily extensible (by merely adding to the tables in ifmedia.h).
 1.62 24-Jan-2000  chopps allow setting (and reporting) nwid for ieee 802.11 devices.
 1.61 24-Jan-2000  thorpej Fix a bug in get_media_options() which wasn't caught with global options;
make sure we only return option bits.
 1.60 12-Jan-2000  joda implement netmask slash notation for IP and IPv6 addresses
 1.59 13-Dec-1999  itojun bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.
 1.58 29-Jul-1999  itojun branches: 1.58.4;
fix alignment problem of SIOCGIFCONF, on 64bit arch.
 1.57 26-Jul-1999  thorpej Make the previous actually compile.
 1.56 26-Jul-1999  darrenr cleanup error message
 1.55 26-Jul-1999  darrenr don't allow destination addresses to be set for non-Point-to-point interfaces
 1.54 03-Jul-1999  sommerfeld Add a new -s option to make it easier to test the link-level status
(i.e., 10baseT carrier/no carrier) of an interface from scripts

ifconfig -s <interface> will exit with a false status if the interface
reports its unconnected.

-s also works in conjunction with -l and -a, filtering out interfaces
which are reporting down.

Also, add -b (which shows only broadcast interfaces with -l and -a).

I find these options useful in network autoconfig scripts for mobile
systems.
 1.53 01-Jul-1999  itojun make ifconfig IPv6-ready.
TODO: update manpage for new options.
 1.52 18-May-1999  thorpej Fix a slight braino in last.
 1.51 17-May-1999  thorpej Don't force `inet' on status display; get all address families that have
configured addresses. From Jun-ichiro itojun Hagino, PR #7593.
 1.50 01-Apr-1999  chopps branches: 1.50.2;
revert the previous changes that removed special cased ioctls for ISO
stuff.
 1.49 06-Sep-1998  christos Add support for displaying interface alias information. Based on PR/6109 by
Phil Nelson.
 1.48 08-Aug-1998  thorpej Oops, add the "instance" command to the usage info.
 1.47 08-Aug-1998  thorpej Allow the user to explicitly set the media instance.
 1.46 08-Aug-1998  thorpej Hm, actions might not always be deferred; rename appropriately.
 1.45 08-Aug-1998  thorpej Completely rewrite the engine that sets media and media options. Previous
code would hit the interface multiple times. Now, all media and media
options are gathered and processed at once, hitting the interface only
once (except to grab the currently selected media exactly once; there is
no way to avoid that).
 1.44 06-Aug-1998  thorpej Implement a suggestion from Wolfgang Solfrank on the "supported media"
display. The display now looks like this:

bishop:thorpej 35$ obj.alpha/ifconfig -m fxp0
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
media: Ethernet autoselect (100baseTX full-duplex)
status: active
supported Ethernet media:
media autoselect
media 100baseTX mediaopt full-duplex
media 100baseTX
media 10baseT mediaopt full-duplex
media 10baseT
media 100baseTX mediaopt loopback
inet 129.99.50.41 netmask 0xffffff00 broadcast 129.99.50.255
bishop:thorpej 36$

The intent here is to allow cut'n'pasting of the output to a command
line, or allow easier automatic extraction from scripts, etc.

XXX Still at issue is what to do about non-0 media instances.
 1.43 06-Aug-1998  thorpej Print the media instance if it's not zero, a reasonable compromise such
that no one will have to see those ugly instance numbers if they have
an interface with only one PHY (most of them out there).
 1.42 06-Aug-1998  thorpej Completely rewrite the way media descriptions are represented. The same
data structure is used, but a much saner matching mechanism is used, one
which allows greater ease in adding new types.

Also, rewrite the way media words are displayed. The status display now
looks like this:

bishop:thorpej 137$ ifconfig -m fxp0
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
media: Ethernet autoselect (10baseT)
status: active
supported media:
Ethernet autoselect
Ethernet 100baseTX <full-duplex>
Ethernet 100baseTX
Ethernet 10baseT <full-duplex>
Ethernet 10baseT
Ethernet 100baseTX <loopback>
inet 129.99.50.41 netmask 0xffffff00 broadcast 129.99.50.255
bishop:thorpej 138$

This makes it more clear which media type (e.g. Ethernet) is currently
in-use, handy for devices such as the TI ThunderLAN which can also have
both Ethernet and Token Ring PHYs attached.
 1.41 05-Aug-1998  thorpej Copyright assigned to The NetBSD Foundation, Inc.
 1.40 01-Oct-1997  enami Don't declare optind.
 1.39 15-Sep-1997  lukem * cleanup for WARNS=1
* deprecate register
* use .Nm correctly
 1.38 08-Sep-1997  mrg note that we have set ifflags so that we can reset them again after
setting the interface address. this is necessary as we may want to
configure an interface `down' by default, but, SIOCAIFADDR turns the
interface back on for us.
 1.37 14-Jul-1997  is ifr_metric vs. ifr_mtu: don't confuse people. Its a union anyway.
 1.36 30-May-1997  lukem Don't define the address of an interface to 0.0.0.0 if it's just being
brought "up" (without an address); don't give it an address at all.
From Koji Imada <koji@math.human.nagoya-u.ac.jp> in [bin/3477]
 1.35 05-May-1997  thorpej Force the ifaliasreq "addreq" to have 4-byte alignment, so that casting
one of its sockaddrs to a sockaddr_in doesn't cause an unaligned access
fault on the Alpha.
 1.34 21-Apr-1997  lukem Implemented two modifier flags for -a and -l: -d (only show "down" interfaces)
and -u (only show "up" interfaces)
 1.33 10-Apr-1997  is Add mtu n parameter. Part of code by Matthias Pfaller (PR 1648).
 1.32 03-Apr-1997  christos - netatalk additions
- KNF
- prototype fixes
- ifconfig -a now prints all the address family parameters for all configured
interfaces.
 1.31 27-Mar-1997  thorpej Add a "-l" flag, which lists available network interfaces, with no
additional information.
 1.30 26-Mar-1997  thorpej Print the station address of interfaces that have one. From
Matt Thomas <matt@3am-software.com>
 1.29 25-Mar-1997  thorpej Display the correct interface name in the event SIOCGIFMEDIA "succeeds"
but doesn't return any media types.
 1.28 24-Mar-1997  thorpej Fix a slight bogon in printing active/current media, from Matt Thomas.
 1.27 18-Mar-1997  thorpej Fix lookup_media_word() to properly distinguish between the "autoselect"
media type and error. (oops!)
 1.26 18-Mar-1997  thorpej Do that last change somewhat differently; We need to know the
currently selected media, and thus cannot allow E2BIG, since the
top-level kernel ioctl code won't perform the copyout of the
ifmediareq if it sees an "error".
 1.25 18-Mar-1997  thorpej Ignore E2BIG in domediaopt() like we do in setmedia(). Oversight pointed
out by Andrew Gallatin <gallatin@CS.Duke.EDU>.
 1.24 17-Mar-1997  thorpej Add support for BSD/OS-style media selection:
- new "media" keyword specified media to select:
ifconfig de0 media utp
- new "mediaopt/-mediaopt" keywords for setting/clearing
media options (such as full-duplex)
- new "-m" flag to display all supported media types for
a given interface.
Also, some generial cleanup of argument parsing while I was there.
Manual page updates from Jeremy Cooper <jeremy@netbsd.org>.
 1.23 08-Sep-1996  mycroft Update to match kernel changes.
 1.22 04-Jan-1996  pk branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.
 1.21 08-Oct-1995  gwr Add support for -DINET_ONLY to make this smaller in a ramdisk.
 1.20 19-May-1995  mycroft Use inet_aton(), not inet_addr(). Suggested by John Hawkinson.
 1.19 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.18 21-Jan-1995  glass fix usage message to include -a. fix command line handling for same
 1.17 18-Dec-1994  cgd spacing nit.
 1.16 05-Dec-1994  cgd more cleanups from Jim Jegers, passed over by me.
 1.15 31-Oct-1994  cgd ioctl types.
 1.14 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.13 23-Sep-1994  mycroft Merge with 4.4-Lite version.
 1.12 22-Jan-1994  cgd (1) update usage info
(2) fix every instance of fprintf/exit except usage to use err()/errx()
(3) make netmask print out with a leading 0x, so that you can paste it back.
 1.11 10-Dec-1993  cgd add MULTICAST recognition
 1.10 10-Dec-1993  cgd LLC -> LINK, documentation
 1.9 01-Aug-1993  mycroft Add RCS identifiers.
 1.8 09-Jun-1993  deraadt removed aui/bnc hack from ifconfig. Use -llc0/llc0 instead.
 1.7 06-Jun-1993  deraadt fix ifconfig once again. multiple protocols really cooked hte code i wrote
before for -a.
 1.6 21-May-1993  cgd Remove ifdefs hiding ISO and XNS functionality
(from Havard Eidnes <Havard.Eidnes@runit.sintef.no>)
 1.5 04-May-1993  deraadt Added another sunos-ism: ifconfig -a
 1.4 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.3 22-Mar-1993  cgd added rcs ids to all files
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 23-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.22.4.1 11-Dec-1996  mycroft From trunk:
Eliminate SS_PRIV; instead, pass down a proc pointer to the usrreq methods
that need it.
Fix numerous memory leaks and bogus return values.
 1.50.2.2 18-Jun-1999  perry pullup 1.51->1.52 (thorpej)
 1.50.2.1 18-Jun-1999  perry pullup 1.50->1.51 (thorpej): Don't force "inet" on status display
 1.58.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.79.4.7 01-May-2001  he Pull up revision 1.107 (via patch, requested by itojun):
Make ``-A'' the default, so that IPv4 aliases are printed.
Always print mac address.
 1.79.4.6 26-Jan-2001  jhawk Pull up revision 1.94 (requested by itojun):
Initialize an uninitialized pointer. PR11702.
 1.79.4.5 31-Dec-2000  jhawk Pull up revision 1.89 (requested by bouyer):
Add support for 802.1Q virtual LANs.
 1.79.4.4 31-Dec-2000  jhawk Pull up revision 1.81, 1.87 (requested by bouyer):
Support cloning of network pseudo-interfaces.
 1.79.4.3 21-Jul-2000  onoe Pullup 802.11 stuff (approved by jhawk)
- add support for nwkey to ifconfig
basesrc/sbin/ifconfig/ifconfig.c 1.88
basesrc/sbin/ifconfig/ifconfig.8 1.39
syssrc/sys/dev/ic/awi.c 1.26
syssrc/sys/dev/ic/awi_wep.c 1.3
syssrc/sys/dev/ic/awivar.h 1.12
syssrc/sys/dev/pcmcia/if_wi.c 1.26
syssrc/sys/net/if.c 1.69
syssrc/sys/net/if_ieee80211.h 1.5
 1.79.4.2 21-Jul-2000  onoe Pullups 802.11 stuff (approved by jhawk)
- allow non-string nwid settings
basesrc/sbin/ifconfig/ifconfig.c 1.82-1.86
basesrc/sbin/ifconfig/ifconfig.8 1.37
syssrc/sys/dev/ic/awi.c 1.21
syssrc/sys/dev/pcmcia/if_ray.c 1.21
syssrc/sys/dev/pcmcia/if_wi.c 1.23
syssrc/sys/dev/pcmcia/if_wivar.h 1.10
syssrc/sys/net/if_ieee80211.h 1.4
 1.79.4.1 30-Jun-2000  thorpej - Add `tunnel' and `deletetunnel' commands, which issue the ioctls
that gifconfig(8) would issue to configure tunnel endpoints. This
allows IP tunnel interfaces (`gif' right now, and `gre' later) to
be configured with ifconfig(8), and via /etc/ifconfig.<interface>.
Partially taken from similar changes in OpenBSD.
- Const poison the command functions a bit. We really need to clean
up the command function interface.

Rationale for pulling into netbsd-1-5 branch: While this looks like
a feature enhancement, it actually fixes a bug -- without this change
or a change in rc.d's network bring-up, it is not possible to configure
IP tunnels as a normal part of bringing up the network.
 1.141.4.2 24-Jul-2005  snj Pull up revision 1.147 via patch (requested by riz in ticket #5518):
Functions for converting media types to/from text are now in libutil.
 1.141.4.1 24-Jul-2005  snj Pull up revision 1.142 (requested by riz in ticket #5517):
The change in revision 1.38 (in 1997!) was wrong. If we don't want the kernel
to automatically bring up interfaces, then we should move that code into
ifconfig(8) and out of the kernel, not cycle the interface up and down. Fixes
PR 9400 -- ifconfig(8) was not working as documented.
 1.152.2.2 14-Oct-2007  riz Pull up following revision(s) (requested by msaitoh in ticket #1801):
sbin/ifconfig/ifconfig.c: revision 1.173 via patch

If the kernel does not set the interface up after we set an address,
do it explicitly, unless we (previously) set it down on user request
(i.e. "ifconfig <name> x.x.x.x down").

This will allow the network drivers to be "fixed" while keeping visible
behaviour the same. Part of fixing PR 30694.
 1.152.2.1 24-Mar-2006  riz Pull up following revision(s) (requested by rpaulo in ticket #1219):
sbin/ifconfig/ifconfig.c: revision 1.169
Added a new ifconfig flag, -h, allowing, in conjunction with -v, the display
of interface I/O bytes in human-format.
Reviewed by Christos Zoulas and Jason Thorpe.
 1.180.6.1 27-Dec-2007  mjf Sync with HEAD.
 1.180.4.1 09-Jan-2008  matt sync with HEAD
 1.181.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.181.4.2 29-Jun-2008  mjf Sync with HEAD.
 1.181.4.1 02-Jun-2008  mjf Sync with HEAD.
 1.181.2.1 22-Feb-2008  keiichi imported Mobile IPv6 code developed by the SHISA project
(http://www.mobileip.jp/).
 1.184.2.3 17-Jun-2008  yamt sync with head.
 1.184.2.2 04-Jun-2008  yamt sync with head
 1.184.2.1 18-May-2008  yamt sync with head.
 1.193.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.193.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.213.2.2 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.213.2.1 04-Apr-2009  snj branches: 1.213.2.1.4;
Pull up following revision(s) (requested by plunky in ticket #665):
sbin/ifconfig/ifconfig.c: revision 1.215
Because the IFF_NOARP flag is a negative option it needs to be negated
when being applied from the "arp" option which itself is positive.
problem demonstrated by
# ifconfig tap3 create
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 arp
# ifconfig tap3
tap3: flags=8882<BROADCAST,NOARP,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 -arp
# ifconfig tap3
tap3: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 destroy
#
 1.213.2.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.214.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.226.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.226.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.226.2.1 17-Apr-2012  yamt sync with head
 1.227.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.227.6.2 25-Feb-2013  tls resync with head
 1.227.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.236.16.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.236.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.236.16.1 10-Jun-2019  christos Sync with HEAD
 1.236.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.236.14.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.249.2.1 24-Aug-2024  martin Pull up following revision(s) (requested by ozaki-r in ticket #811):

tests/net/if_shmif/t_shmif.sh: revision 1.1
sbin/ifconfig/ifconfig.c: revision 1.251
sbin/ifconfig/ifconfig.8: revision 1.130
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.85
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.86
sys/rump/net/lib/libshmif/if_shmem.c: revision 1.87
etc/mtree/NetBSD.dist.tests: revision 1.206
distrib/sets/lists/tests/mi: revision 1.1333
tests/net/if_shmif/Makefile: revision 1.1
tests/net/Makefile: revision 1.42

shmif: change behaviors about link states

- Change the link state to UP on ifconfig linkstr
- This behavior emulates physical devices
- Change the link state to UNKNOWN on ifconfig -linkstr just in case
- Reject sending/receiving packets if the link state is DOWN
- Permit to send/receive packets on UNKNOWN, which is required
to unbreak some ATF tests written in C

shmif: support media

It enables to link-down shmif by ifconfig media none and link-up
again by media auto.

ifconfig: show link state on -v

We could guess it through "media" or "status" output, however, we
sometimes want to know it directly for debugging or testing.

It is shown only if the -v option is specified.
tests: add tests for shmif

The test file is placed under tests/net, not tests/rump/rumpnet,
to leverage utility functions provided for tests in there.
shmem(4): Fix typo in comment: AFT -> ATF.

Also fix grammar (if I understood correctly what this meant: rump
servers written in C, rather than set up via shell scripts around
rump_server invoking ifconfig).

No functional change intended.
 1.250.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.1 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.2 19-Sep-2025  knakahara ifconfig(8): show missing l2tp-state of l2tp(4).
 1.1 16-Feb-2017  knakahara branches: 1.1.2; 1.1.4;
add l2tp(4) subcomands to ifconfig(8).

originally implemented by IIJ SEIL team.
 1.1.4.2 21-Apr-2017  bouyer Sync with HEAD
 1.1.4.1 16-Feb-2017  bouyer file l2tp.c was added on branch bouyer-socketcan on 2017-04-21 16:53:13 +0000
 1.1.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.1 16-Feb-2017  pgoyette file l2tp.c was added on branch pgoyette-localcount on 2017-03-20 06:57:02 +0000
 1.8 09-Apr-2024  yamaguchi lagg(4): allocate memory for struct lagg_req by calloc(3)
to fix build error on clang
 1.7 08-Apr-2024  yamaguchi lagg(4): fix missing initialization of the number of array

pointed out by martin@, thanks.
 1.6 04-Apr-2024  yamaguchi ifconfig: remove optional space
 1.5 04-Apr-2024  yamaguchi lagg(4): use flexible array member
 1.4 06-Dec-2023  yamaguchi Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.
 1.3 31-Mar-2022  yamaguchi branches: 1.3.2;
Change error code to ENOBUFS on lack of buffer memory

pointed out by k-goda@IIJ
 1.2 21-Jun-2021  christos fix proplib deprecation
 1.1 17-May-2021  yamaguchi branches: 1.1.2;
Add a new link-aggregation pseudo interface named lagg(4)

- FreeBSD's lagg(4) based implementation
- MP-safe and MP-scalable
 1.1.2.2 31-May-2021  cjep sync with head
 1.1.2.1 17-May-2021  cjep file lagg.c was added on branch cjep_staticlib_x on 2021-05-31 22:15:08 +0000
 1.3.2.1 12-Dec-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #491):

sys/net/lagg/if_lagg.c: revision 1.56
sys/net/lagg/if_lagg.c: revision 1.57
sbin/ifconfig/lagg.c: revision 1.4

lagg(4): use sadl for lagg(4) configured by a user

lagg(4): eliminate unnecessary reset by the change of if_flags

Fix "ifconfig lagg* lagglacp -maxports" command

This command clears the setting of the maximum number of
lacp active ports. The command was accepted but it did not
work until this change.
 1.14 04-Apr-2022  andvar fix various typos, mainly in comments.
 1.13 14-Oct-2020  roy ifconfig: go back to using direct ioctls rather than data from getifaddrs

AF_LINK may not be the first address returned for the interface.
Technically, it *might* not even exist on the interface even though
other families do.
This is likely a driver bug if this really is the case though.

As such it's just easier to use direct ioctls rather than thump around
getifaddrs results. As it stands, the code makes a lot of getifaddrs
calls anyway, so an extra ioctl or two won't break the bank.
 1.12 05-Oct-2020  roy Minor correction to prior
 1.11 05-Oct-2020  roy ifconfig: Warn once more if media supported but no types

This reverts media.c -r1.7
 1.10 22-Sep-2020  roy ifconfig: Report link state even if media is not supported

For AF_LINK addrs from getifaddrs(2), ifa_data is struct if_data.
This in turn holds ifi_link_state which we can use to report
link status if the interface does not support media where it's normally
reported.

Based on OpenBSD.
 1.9 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.8 22-Apr-2019  msaitoh Suggested by Christos:
- Dont' cast malloc()'s return value.
- Use calloc() instead of malloc().
 1.7 14-Sep-2016  roy branches: 1.7.14;
Don't bail if SIOGIFMEDIA doesn't return any media lists because we
can still report link status.
 1.6 29-Aug-2011  joerg branches: 1.6.24;
Use __dead
 1.5 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.4 01-Jul-2010  dyoung Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.3 15-Jul-2008  dyoung branches: 1.3.2; 1.3.4;
Cosmetic: s/xenv/oenv/
 1.2 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.1 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.3.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.4.1 15-Jul-2008  mjf file media.c was added on branch mjf-devfs2 on 2008-09-28 11:17:11 +0000
 1.3.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1 15-Jul-2008  wrstuden file media.c was added on branch wrstuden-revivesa on 2008-09-18 04:28:25 +0000
 1.6.24.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7.14.1 10-Jun-2019  christos Sync with HEAD
 1.3 14-Oct-2020  roy ifconfig: go back to using direct ioctls rather than data from getifaddrs

AF_LINK may not be the first address returned for the interface.
Technically, it *might* not even exist on the interface even though
other families do.
This is likely a driver bug if this really is the case though.

As such it's just easier to use direct ioctls rather than thump around
getifaddrs results. As it stands, the code makes a lot of getifaddrs
calls anyway, so an extra ioctl or two won't break the bank.
 1.2 22-Sep-2020  roy ifconfig: Report link state even if media is not supported

For AF_LINK addrs from getifaddrs(2), ifa_data is struct if_data.
This in turn holds ifi_link_state which we can use to report
link status if the interface does not support media where it's normally
reported.

Based on OpenBSD.
 1.1 02-Jul-2008  dyoung branches: 1.1.2; 1.1.4;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.1.4.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.4.1 02-Jul-2008  mjf file media.h was added on branch mjf-devfs2 on 2008-09-28 11:17:12 +0000
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 02-Jul-2008  wrstuden file media.h was added on branch wrstuden-revivesa on 2008-09-18 04:28:25 +0000
 1.20 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.19 16-Aug-2019  msaitoh Whitespace fix.
 1.18 17-Jul-2013  christos branches: 1.18.28;
print the next parser name instead of just the pointer in debugging.
 1.17 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.16 01-Jul-2010  dyoung branches: 1.16.6; 1.16.12;
Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.15 20-Apr-2010  plunky C99 says that offsetof() expands to a constant expresssion, so we
can't use variable array index in there. Do the calculation manually
for C99 compilers (pcc)
 1.14 28-Jul-2009  dyoung Both carp.c and vlan.c expect for a keyword with a KW_T_STR-type
value to put a prop_string_t into the environment, but the keyword
parser put a prop_data_t into the environment, instead. That broke
the -vlanif and -carpdev keywords and defied developer expectations.
Let's put a prop_string_t into the environment.

Thanks to Arnaud Degroote for reporting the problem.
 1.13 18-Jan-2009  lukem fix -Wsign-compare issues
 1.12 01-Aug-2008  dyoung branches: 1.12.2; 1.12.4; 1.12.6;
Extract common code. Create subroutine paddr_prefix_size().
 1.11 01-Aug-2008  dyoung Always initialize the union of sockaddrs. I used to initialize it
only in the AF_UNSPEC/AF_INET/AF_INET6 cases. Maybe this will fix
the AF_APPLETALK problem that is@ reports:

random84# ifconfig nfe0 atalk 3.14
ifconfig: SIOCAIFADDR: Invalid argument
 1.10 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.9 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.8 19-May-2008  dyoung branches: 1.8.2;
Fix two bugs:

1 Let us associate a keyword with either a signed or an unsigned
number. Associate the '-chan' keyword with an unsigned number.
This fixes the defect that crashed 'ifconfig wi0 -chan', reported
by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
address family was specified. iso_addr(3) does not report errors,
so it appears to interpret *everything* as an ISO address. This
is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
!INET6 kernel that deletes the first IPv4 address on lo0.
(Reported by Scott Ellis.)
 1.7 12-May-2008  dyoung branches: 1.7.2;
Fix link-layer address parsing. Add debug statements.

Cosmetic: fix copyright whitespace.
 1.6 12-May-2008  dyoung Add code for parsing link-layer addresses of the form xx:xx:...:xx.
 1.5 09-May-2008  dyoung In address, integer, string parsers, gracefully handle a missing
token.
 1.4 07-May-2008  dyoung Fix a bug that I introduced in rev 1.88, where the default IPv6
prefix length changed from 64 to 128. While I am here, allow an
address to be given with prefix length /0, but interpret it as
/128.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3).
 1.2 06-May-2008  dyoung Add a license.
 1.1 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.3.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.2.3 04-Jun-2008  yamt sync with head
 1.7.2.2 18-May-2008  yamt sync with head.
 1.7.2.1 12-May-2008  yamt file parse.c was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.8.2.3 28-Sep-2008  mjf Sync with HEAD.
 1.8.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.2.1 19-May-2008  mjf file parse.c was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.12.6.1 21-Apr-2010  matt sync to netbsd-5
 1.12.4.1 14-Aug-2009  snj Pull up following revision(s) (requested by dyoung in ticket #878):
sbin/ifconfig/parse.c: revision 1.14
Both carp.c and vlan.c expect for a keyword with a KW_T_STR-type
value to put a prop_string_t into the environment, but the keyword
parser put a prop_data_t into the environment, instead. That broke
the -vlanif and -carpdev keywords and defied developer expectations.
Let's put a prop_string_t into the environment.
Thanks to Arnaud Degroote for reporting the problem.
 1.12.2.1 14-Aug-2009  snj Pull up following revision(s) (requested by dyoung in ticket #878):
sbin/ifconfig/parse.c: revision 1.14
Both carp.c and vlan.c expect for a keyword with a KW_T_STR-type
value to put a prop_string_t into the environment, but the keyword
parser put a prop_data_t into the environment, instead. That broke
the -vlanif and -carpdev keywords and defied developer expectations.
Let's put a prop_string_t into the environment.
Thanks to Arnaud Degroote for reporting the problem.
 1.16.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.12.1 23-Jun-2013  tls resync from head
 1.16.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.28.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9 16-Aug-2019  msaitoh Whitespace fix.
 1.8 30-Jun-2019  sevan Add rcsid
 1.7 01-Jul-2010  dyoung branches: 1.7.46;
Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.6 01-Aug-2008  dyoung Extract common code. Create subroutine paddr_prefix_size().
 1.5 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.4 19-May-2008  dyoung branches: 1.4.2;
Fix two bugs:

1 Let us associate a keyword with either a signed or an unsigned
number. Associate the '-chan' keyword with an unsigned number.
This fixes the defect that crashed 'ifconfig wi0 -chan', reported
by Michael van Elst.

2 Do not try to interpret names as ISO addresses unless the ISO
address family was specified. iso_addr(3) does not report errors,
so it appears to interpret *everything* as an ISO address. This
is a stopgap fix for the defect in 'ifconfig lo0 inet6' on a
!INET6 kernel that deletes the first IPv4 address on lo0.
(Reported by Scott Ellis.)
 1.3 07-May-2008  dyoung branches: 1.3.2;
Move IPv6 syntax to af_inet6.c from ifconfig.c. Move IFKW() macro
from ifconfig.c to parse.h for reuse.
 1.2 07-May-2008  dyoung Fix a bug that I introduced in rev 1.88, where the default IPv6
prefix length changed from 64 to 128. While I am here, allow an
address to be given with prefix length /0, but interpret it as
/128.
 1.1 06-May-2008  dyoung branches: 1.1.2;
Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.1.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.2.3 04-Jun-2008  yamt sync with head
 1.3.2.2 18-May-2008  yamt sync with head.
 1.3.2.1 07-May-2008  yamt file parse.h was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.4.2.3 28-Sep-2008  mjf Sync with HEAD.
 1.4.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.1 19-May-2008  mjf file parse.h was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.7.46.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4 21-Jun-2021  christos fix proplib deprecation
 1.3 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.2 16-Aug-2019  msaitoh Whitespace fix.
 1.1 14-Sep-2009  degroote branches: 1.1.46;
Import pfsync support from OpenBSD 4.2

Pfsync interface exposes change in the pf(4) over a pseudo-interface, and can
be used to synchronise different pf.

This work was part of my 2009 GSoC

No objection on tech-net@
 1.1.46.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 13-Dec-2010  pooka use crunchops for crunchables
 1.2 13-Dec-2010  njoly op_read return value is a ssize_t, not an int.
 1.1 13-Dec-2010  pooka Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.22 07-Jun-2020  thorpej Update for proplib(3) API changes.
 1.21 16-Aug-2019  msaitoh Whitespace fix.
 1.20 19-Oct-2013  christos branches: 1.20.26;
use correct function
 1.19 19-Oct-2013  christos use symbolic flags
 1.18 19-Oct-2013  christos use the new scopeid functions
 1.17 07-Aug-2009  dyoung branches: 1.17.6; 1.17.12;
Add option -N. -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
 1.16 15-Jul-2008  dyoung Cosmetic: s/xenv/oenv/
 1.15 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.14 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.13 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.12 07-May-2008  dyoung Move tunnel syntax into tunnel.c. Move net80211 'list' command
syntax into ieee80211.c.
 1.11 06-May-2008  dyoung branches: 1.11.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.10 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.9 26-Mar-2007  dyoung branches: 1.9.12; 1.9.14;
Don't try to convert numbers to names for either endpoint of a
tunnel. In this way, ifconfig will avoid emitting something
abominable like this:

tunnel 192.168.1.1,mdns --> 192.168.1.2,kazaa
 1.8 31-Aug-2006  dyoung Add a mode to gre(4) that sends GRE tunnel packets in UDP datagrams.
Fix MOBILE encapsulation. Add many debugging printfs (mainly
concerning UDP mode). Clean up the gre(4) code a bit. Add the
capability to setup UDP tunnels to ifconfig. Update documentation.

In UDP mode, gre(4) puts a GRE header onto transmitted packets,
and hands them to a UDP socket for transmission. That is, the
encapsulation looks like this: IP+UDP+GRE+encapsulated packet.

There are two ways to set up a UDP tunnel. One way is to tell the
source and destination IP+port to gre(4), and let gre(4) create
the socket. The other way to create a UDP tunnel is for userland
to "delegate" a UDP socket to the kernel.
 1.7 26-Aug-2006  christos Programs that use efun.
 1.6 16-Jun-2006  elad fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

okay christos
 1.5 20-Mar-2005  thorpej Split IPv6 support out into its own file.
 1.4 19-Mar-2005  thorpej const'ify afswtch
 1.3 19-Mar-2005  thorpej Don't hare-code inet/inet6 in tunnel_status(), lookup the address family
name instead.
 1.2 19-Mar-2005  yamt make this compilable with USE_INET6=no.
 1.1 19-Mar-2005  thorpej Split tunnel support into its own file.
 1.9.14.1 18-May-2008  yamt sync with head.
 1.9.12.2 28-Sep-2008  mjf Sync with HEAD.
 1.9.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.4 07-May-2008  dyoung Move tunnel syntax into tunnel.c. Move net80211 'list' command
syntax into ieee80211.c.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 19-Mar-2005  thorpej branches: 1.1.20; 1.1.22;
Split tunnel support into its own file.
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.20 11-Oct-2020  roy ifconfig: if SIOCGLIFADDR fails, continue to the next address
 1.19 01-Oct-2019  kardel PR/54513 ifconfig exits on newly created carp interfaces
downgrade from err(EXIT_FAILURE, ... ) to warn() if ioctl(SIOCGLIFADDR) fails.
ifconfig now survives freshly created carp interfaces.
 1.18 16-Aug-2019  msaitoh Whitespace fix.
 1.17 19-Oct-2013  christos branches: 1.17.26;
use the new scopeid functions
 1.16 13-Dec-2010  pooka branches: 1.16.6; 1.16.12;
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.
 1.15 01-Jul-2010  dyoung Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.14 01-Jul-2010  dyoung Change a > to a >= to avoid writing to the character after the end of
the buffer passed to get_string().
 1.13 11-Sep-2009  dyoung Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
 1.12 07-Aug-2009  dyoung Add option -N. -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
 1.11 27-Apr-2009  dyoung Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.

Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.10 21-Apr-2009  dyoung To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
 1.9 18-Jan-2009  lukem branches: 1.9.2;
fix -Wsign-compare issues
 1.8 02-Jul-2008  dyoung branches: 1.8.2; 1.8.6;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.7 13-May-2008  dyoung branches: 1.7.2; 1.7.4;
Use an AF_LINK socket to add/delete/get link-layer addresses.
 1.6 12-May-2008  dyoung Cosmetic: fix copyright whitespace.
 1.5 12-May-2008  dyoung We cannot create an AF_LINK socket. If AF_LINK is requested, create
an AF_INET socket, instead.
 1.4 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.3 07-May-2008  dyoung Interpret 'prefixlen 0' as the maximum prefix length, as ifconfig
has always done.
 1.2 06-May-2008  dyoung branches: 1.2.2;
Add a license.
 1.1 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.2.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.7.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.7.4.1 13-May-2008  mjf file util.c was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.7.2.2 18-May-2008  yamt sync with head.
 1.7.2.1 13-May-2008  yamt file util.c was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.8.6.1 21-Apr-2010  matt sync to netbsd-5
 1.8.2.1 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.9.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.16.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.26.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13 30-Jun-2019  sevan Add rcsid
 1.12 07-Jan-2016  roy branches: 1.12.16;
-W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
 1.11 22-Apr-2015  roy Move the INET6 specific code for wait_dad_exec() into af_inet6
by using a new afswtch hook af_addr_tentative.
 1.10 19-Oct-2013  christos use the new scopeid functions
 1.9 01-Jul-2010  dyoung branches: 1.9.6; 1.9.12;
Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it. (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.
 1.8 11-Sep-2009  dyoung Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
 1.7 21-Apr-2009  dyoung To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
 1.6 02-Jul-2008  dyoung branches: 1.6.2; 1.6.4; 1.6.8;
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.5 03-Jun-2008  dyoung Remove remnants of struct afswtch.af_getprefix().
 1.4 07-May-2008  dyoung branches: 1.4.2; 1.4.4;
Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Rename in_addr_commit() to commit_address(), and refactor slightly
to support IPv6 as well as IPv4 (a work in progress).

Make the second argument of af_status() a bool instead of an int.

Exit early with an error if the operator specifies an unsupported
address family on the command line. The change should help rc
scripts to detect that IPv6 support is missing from the kernel,
with 'ifconfig lo0 inet6'.

Start using prop_dictionary_util(3).
 1.1 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.3.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.4.4 28-Sep-2008  mjf Sync with HEAD.
 1.4.4.3 29-Jun-2008  mjf Sync with HEAD.
 1.4.4.2 02-Jun-2008  mjf Sync with HEAD.
 1.4.4.1 07-May-2008  mjf file util.h was added on branch mjf-devfs2 on 2008-06-02 13:21:22 +0000
 1.4.2.3 17-Jun-2008  yamt sync with head.
 1.4.2.2 18-May-2008  yamt sync with head.
 1.4.2.1 07-May-2008  yamt file util.h was added on branch yamt-pf42 on 2008-05-18 12:30:53 +0000
 1.6.8.1 21-Apr-2010  matt sync to netbsd-5
 1.6.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.6.2.1 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.9.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16 21-Jun-2021  christos fix proplib deprecation
 1.15 16-Aug-2019  msaitoh Whitespace fix.
 1.14 15-Sep-2014  ozaki-r branches: 1.14.16;
Add -vlanif to the help message of ifconfig

PR 49114
 1.13 28-Jul-2009  dyoung branches: 1.13.8; 1.13.24;
Don't require a "vlan" argument with "-vlanif". "ifconfig vlan0
-vlanif" works as one would expect, now.
 1.12 15-Jul-2008  dyoung branches: 1.12.2; 1.12.6; 1.12.8;
Cosmetic: s/xenv/oenv/
 1.11 15-Jul-2008  dyoung Only describe flags -L and -m in the usage if they are available.
That helps me get rid of some conditional compilation (INET6) in
ifconfig.

Let each protocol/feature-module print its own usage, so that the
ifconfig usage reflects the modules that are actually compiled-in.

Write usage information for carp(4) options.
 1.10 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.9 16-May-2008  dyoung The key 'vlantag' activates the 'vlanif' keyword, not the key
'vlan'. Should fix this bug reported by Pierre Pronchery,

# ifconfig vlan0 vlan 1 vlanif hme0
ifconfig: SIOCAIFADDR: Address family not supported by protocol family
 1.8 07-May-2008  dyoung Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
 1.7 07-May-2008  dyoung Move vlan(4) syntax from ifconfig.c into vlan.c.
 1.6 06-May-2008  dyoung branches: 1.6.2;
Use prop_dictionary_util(3).
 1.5 06-May-2008  dyoung Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.4 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.3 19-Mar-2005  thorpej branches: 1.3.20; 1.3.22;
name -> ifname (avoid shadow decl with global name[]).
 1.2 19-Mar-2005  thorpej Move extern decls to extern.h
 1.1 19-Mar-2005  thorpej Split VLAN configuration bits out into a separate file.
 1.3.22.1 18-May-2008  yamt sync with head.
 1.3.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.8.1 21-Apr-2010  matt sync to netbsd-5
 1.12.6.1 14-Aug-2009  snj Pull up following revision(s) (requested by dyoung in ticket #879):
sbin/ifconfig/vlan.c: revision 1.13
Don't require a "vlan" argument with "-vlanif". "ifconfig vlan0
-vlanif" works as one would expect, now.
 1.12.2.1 14-Aug-2009  snj Pull up following revision(s) (requested by dyoung in ticket #879):
sbin/ifconfig/vlan.c: revision 1.13
Don't require a "vlan" argument with "-vlanif". "ifconfig vlan0
-vlanif" works as one would expect, now.
 1.13.24.1 22-Sep-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #108):
sbin/ifconfig/vlan.c: revision 1.14
sbin/ifconfig/ifconfig.8: revision 1.108
sys/net/if_vlan.c: revision 1.71-1.74

Document -vlanif in ifconfig.8 and in usage measseg (PR 49114).
Leave promiscuous mode when detaching a parent (PR 49196) and
delete link local addresses (49197).
Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig
(PR 49112).
Call if_input of vlan interface itself, not parent one.
This allows bridging vlan interfaces again.
 1.13.8.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by ozaki-r in ticket #1156):
sbin/ifconfig/vlan.c: revision 1.14
sbin/ifconfig/ifconfig.8: revision 1.108
sys/net/if_vlan.c: revision 1.71
sys/net/if_vlan.c: revision 1.73
sys/net/if_vlan.c: revision 1.74
- PR#49114: Write about -vlanif in ifconfig.8.
Add -vlanif to the help message of ifconfig.
- PR#49196: Leave promiscuous mode when detaching a parent (ifconfig -vlanif)
We have to call ifpromisc(ifp, 0) for both a VLAN interface
and its parent when they are in promiscuous mode.
- PR#49197: Delete link local addresses of a vlan interface when detaching its
parent.
- PR#49112: Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig
 1.14.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 02-Jul-2008  dyoung Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.

(In principle, ifconfig could load virtually all of its syntax from
shared objects.)

Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.

Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.

Sprinkle static. Change some int's to bool's. Constify.

Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.

Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.

Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
 1.4 07-May-2008  dyoung Move vlan(4) syntax from ifconfig.c into vlan.c.
 1.3 06-May-2008  dyoung branches: 1.3.2;
Use prop_dictionary_util(3) some more.

When we read interface flags and capabilities from the kernel, take
care not to record them in our current environment (env), but record
them in the output environment (oenv), instead. This helps us get
interface capabilities and flags right.
 1.2 06-May-2008  dyoung Overhaul ifconfig. Use fewer global variables. Take a leap toward
improved modularity and extensibility.

In the new architecture, a directed graph of argument-matching
objects (match objects) expresses the set of feasible ifconfig
statements. Match objects are labelled by subroutines that provide
the statement semantics.

Many IPv4, IPv6, 802.11, tunnel, and media configurations have been
tested.

AppleTalk, ISO, carp(4), agr(4), and vlan(4) configuration need
testing.
 1.1 19-Mar-2005  thorpej branches: 1.1.20; 1.1.22;
Split VLAN configuration bits out into a separate file.
 1.1.22.1 18-May-2008  yamt sync with head.
 1.1.20.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 07-Sep-2008  wrstuden Delete a bunch of things that are now gone in head.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.

RSS XML Feed