History log of /netbsd-current/sbin/ifconfig/ifconfig.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.250 03-Jan-2024 andvar

s/addreseses/addresses/ in comments (and one missing whitespace).


Revision tags: netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.249 25-Nov-2022 knakahara

ifconfig(8) support unnumbered flag.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.249 25-Nov-2022 knakahara

ifconfig(8) support unnumbered flag.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.242 07-Jun-2020 thorpej

Update for proplib(3) API changes.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.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)


Revision tags: phil-wifi-20191119
# 1.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-0-RC1 netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.240 16-Aug-2019 msaitoh

Whitespace fix.


Revision tags: netbsd-9-base
# 1.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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.239 04-Jul-2019 ozaki-r

Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.

From t-kusaba@IIJ


Revision tags: phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.238 21-Dec-2018 msaitoh

Add SIOCSETHERCAP. It's used to change ec_capenable.


Revision tags: pgoyette-compat-1126
# 1.237 15-Nov-2018 ozaki-r

ifconfig: add linkstr/-linkstr to the help message


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.236 07-Jan-2016 roy

branches: 1.236.14;
-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@


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.236 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.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@


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.231 19-Oct-2013 christos

use the new scopeid functions


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.230 17-Jul-2013 christos

Allow -v to be used with other commands (list scan for example) as documented.


Revision tags: agc-symver-base
# 1.229 07-Feb-2013 apb

Abort on error from prop_dictionary_augment.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7
# 1.228 01-Nov-2012 pgoyette

Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 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.)


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.226 29-Aug-2011 joerg

branches: 1.226.2;
Use __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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.


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 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


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 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.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 wrstuden-revivesa-base
# 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().


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase
# 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.)


Revision tags: yamt-pf42-base2
# 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.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 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.


Revision tags: keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 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


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 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.


Revision tags: abandoned-netbsd-4-base
# 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.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 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.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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.


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.59 13-Dec-1999 itojun

bring in KAME scopeid hack. always show scopeid if it is scoped.
sync with latest KAME.


Revision tags: comdex-fall-1999-base
# 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.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 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.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.22 04-Jan-1996 pk

branches: 1.22.4;
Agree with kernel on format of SIOCGIFCONF results.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 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.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.4 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.3 22-Mar-1993 cgd

added rcs ids to all files


Revision tags: patchkit-0-2-2
# 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